Renamed the uikit lib folders. Resolved the gh-188 by updateing the note. Resolved gh-92 by implementation of the library manager in the compiler.
This commit is contained in:
62
media/uikit-v2/js/core/smooth-scroll.js
Normal file
62
media/uikit-v2/js/core/smooth-scroll.js
Normal file
@ -0,0 +1,62 @@
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
(function(UI) {
|
||||
|
||||
"use strict";
|
||||
|
||||
UI.component('smoothScroll', {
|
||||
|
||||
boot: function() {
|
||||
|
||||
// init code
|
||||
UI.$html.on('click.smooth-scroll.uikit', '[data-uk-smooth-scroll]', function(e) {
|
||||
var ele = UI.$(this);
|
||||
|
||||
if (!ele.data('smoothScroll')) {
|
||||
var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr('data-uk-smooth-scroll')));
|
||||
ele.trigger('click');
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
init: function() {
|
||||
|
||||
var $this = this;
|
||||
|
||||
this.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$('body'), $this.options);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function scrollToElement(ele, options) {
|
||||
|
||||
options = UI.$.extend({
|
||||
duration: 1000,
|
||||
transition: 'easeOutExpo',
|
||||
offset: 0,
|
||||
complete: function(){}
|
||||
}, options);
|
||||
|
||||
// get / set parameters
|
||||
var target = ele.offset().top - options.offset,
|
||||
docheight = UI.$doc.height(),
|
||||
winheight = window.innerHeight;
|
||||
|
||||
if ((target + winheight) > docheight) {
|
||||
target = docheight - winheight;
|
||||
}
|
||||
|
||||
// animate to target, fire callback when done
|
||||
UI.$('html,body').stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete);
|
||||
}
|
||||
|
||||
UI.Utils.scrollToElement = scrollToElement;
|
||||
|
||||
if (!UI.$.easing.easeOutExpo) {
|
||||
UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; };
|
||||
}
|
||||
|
||||
})(UIkit2);
|
Reference in New Issue
Block a user