casper/assets/js/index.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* Main JS file for Casper behaviours
*/
/* globals jQuery, document */
(function ($, undefined) {
"use strict";
var $document = $(document);
$document.ready(function () {
var $postContent = $(".post-content");
$postContent.fitVids();
2014-07-22 11:21:33 +00:00
$(".scroll-down").arctic_scroll();
});
2013-08-20 16:53:02 +00:00
// Arctic Scroll by Paul Adam Davis
// https://github.com/PaulAdamDavis/Arctic-Scroll
2014-07-22 11:21:33 +00:00
$.fn.arctic_scroll = function (options) {
var defaults = {
elem: $(this),
speed: 500
},
2014-07-22 11:21:33 +00:00
allOptions = $.extend(defaults, options);
allOptions.elem.click(function (event) {
2014-07-22 11:21:33 +00:00
event.preventDefault();
var $this = $(this),
$htmlBody = $('html, body'),
offset = ($this.attr('data-offset')) ? $this.attr('data-offset') : false,
position = ($this.attr('data-position')) ? $this.attr('data-position') : false,
toMove;
2014-07-22 11:21:33 +00:00
if (offset) {
toMove = parseInt(offset);
$htmlBody.stop(true, false).animate({scrollTop: ($(this.hash).offset().top + toMove) }, allOptions.speed);
2014-07-22 11:21:33 +00:00
} else if (position) {
toMove = parseInt(position);
$htmlBody.stop(true, false).animate({scrollTop: toMove }, allOptions.speed);
2014-07-22 11:21:33 +00:00
} else {
$htmlBody.stop(true, false).animate({scrollTop: ($(this.hash).offset().top) }, allOptions.speed);
2014-07-22 11:21:33 +00:00
}
});
};
})(jQuery);