Moved general utils into another file
This commit is contained in:
parent
5799675878
commit
9550cf65f7
2 changed files with 19 additions and 17 deletions
|
@ -1,25 +1,11 @@
|
||||||
/* global $ */
|
/* global $ */
|
||||||
|
require('./utils.js');
|
||||||
|
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var ProjectImagesTypes = require('./components/project-images-types');
|
var ProjectImagesTypes = require('./components/project-images-types');
|
||||||
var ProjectImagesMain = require('./components/project-images-main');
|
var ProjectImagesMain = require('./components/project-images-main');
|
||||||
|
|
||||||
$(function() { // https://css-tricks.com/snippets/jquery/smooth-scrolling/
|
if ($('body').hasClass('index')) { // Render components on index
|
||||||
$('a[href*=#]:not([href=#])').click(function() {
|
|
||||||
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '')
|
|
||||||
&& location.hostname === this.hostname) {
|
|
||||||
var target = $(this.hash);
|
|
||||||
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
|
||||||
if (target.length) {
|
|
||||||
$('html,body').animate({
|
|
||||||
scrollTop: target.offset().top
|
|
||||||
}, 1000);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($('body').hasClass('index')) {
|
|
||||||
React.render(<ProjectImagesTypes />, document.getElementById('project-images-types'));
|
React.render(<ProjectImagesTypes />, document.getElementById('project-images-types'));
|
||||||
React.render(<ProjectImagesMain />, document.getElementById('project-images-main'));
|
React.render(<ProjectImagesMain />, document.getElementById('project-images-main'));
|
||||||
}
|
}
|
||||||
|
|
16
static/src/js/utils.js
Normal file
16
static/src/js/utils.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/* global $ */
|
||||||
|
$(function() { // https://css-tricks.com/snippets/jquery/smooth-scrolling/
|
||||||
|
$('a[href*=#]:not([href=#])').click(function() {
|
||||||
|
if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '')
|
||||||
|
&& location.hostname === this.hostname) {
|
||||||
|
var target = $(this.hash);
|
||||||
|
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
||||||
|
if (target.length) {
|
||||||
|
$('html,body').animate({
|
||||||
|
scrollTop: target.offset().top
|
||||||
|
}, 1000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Reference in a new issue