Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a second parameter to setScrollTop. Fixes #149

The second parameter `force` can be set to true if no transition is desired.
Skrollr will then jump straight to the new position.
  • Loading branch information...
commit a82abf286863becf8d59e3e7317d45acb3818a51 1 parent 89e174e
@Prinzhorn authored
View
4 README.md
@@ -422,10 +422,12 @@ var offset = s.relativeToAbsolute(document.getElementById('foo'), 'top', 'bottom
Returns the current scroll offset in pixels. Normalizes different browser quirks and returns the iScroll y-position in case of skrollr.mobile.
-### setScrollTop(top)
+### setScrollTop(top[, force = false])
Sets the top offset using `window.scrollTo(0, top)` on dektop or `iscroll.scrollTo(0, -top)` when using skrollr.mobile.
+When `force` is set to `true`, skrollr will jump to the new position without any kind of transition. By default the global `smoothScrolling` setting applies.
+
### animateTo(top[, options])
Animates the scroll position from current position to `top`. Possible options are
View
2  dist/skrollr.min.js
@@ -1,2 +1,2 @@
/*! skrollr v0.5.14 https://github.com/Prinzhorn/skrollr | free to use under terms of MIT license */
-(function(e,t,n){"use strict";function j(n){s=t.documentElement,o=t.body,H(),tt=this,n=n||{},ut=n.constants||{};if(n.easing)for(var i in n.easing)B[i]=n.easing[i];rt={beforerender:n.beforerender,render:n.render},it=n.forceHeight!==!1,ht=n.smoothScrolling!==!1,pt={targetTop:tt.getScrollTop()},it&&(ot=n.scale||1),Q(s,[l],[c]);if(it){var u=t.getElementById("skrollr-body")||t.createElement("div"),a=u.style;a.minWidth="1px",a.position="absolute",a.top=a.zIndex="0",u.id||(a.width="1px",a.right="0",o.appendChild(u)),function(e){$=function(){e.apply(this,arguments),a.height=st+s.clientHeight+"px"}}($)}return tt.refresh(),r.addEvent(e,"resize",$),function f(){S(f),q()}(),tt}var r=e.skrollr={get:function(){return tt},init:function(e){return tt||new j(e)},VERSION:"0.5.14"},i=Object.prototype.hasOwnProperty,s,o,u="rendered",a="un"+u,f="skrollable",l="skrollr",c="no-"+l,h="linear",p=1e3,d=200,v="start",m="end",g="top",y="center",b="bottom",w="___has_rendered_class",E="___skrollable_id",S=e.requestAnimationFrame;(function(){var t=["ms","moz","webkit","o"],n;for(n=0;n<t.length&&!S;n++)S=e[t[n]+"RequestAnimationFrame"];var r=0;S||(S=function(t){var n=Z(),i=Math.max(0,30-(n-r));e.setTimeout(function(){t(n+i)},i),r=n+i})})();var x=/^\s*(.+)\s*$/m,T=/^data(?:-(_\w+))?(?:-?(-?\d+))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/,N=/\s*([a-z\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,C=/^([a-z\-]+)\[(\w+)\]$/,k=/-([a-z])/g,L=function(e,t){return t.toUpperCase()},A=/[\-+]?[\d]*\.?[\d]+/g,O=/\{\?\}/g,M=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,_=/[a-z\-]+-gradient/g,D,P,H=function(){var t=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;if(e.getComputedStyle){var n=e.getComputedStyle(o,null);for(var r in n){D=r.match(t)||+r==r&&n[r].match(t);if(D)break}D&&(D=D[0],D.slice(0,1)==="-"?(P=D,D={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[D]):P="-"+D.toLowerCase()+"-")}},B={begin:function(){return 0},end:function(){return 1},linear:function(e){return e},quadratic:function(e){return e*e},cubic:function(e){return e*e*e},swing:function(e){return-Math.cos(e*Math.PI)/2+.5},sqrt:function(e){return Math.sqrt(e)},bounce:function(e){var t;if(e<=.5083)t=3;else if(e<=.8489)t=9;else if(e<=.96208)t=27;else{if(!(e<=.99981))return 1;t=91}return 1-Math.abs(3*Math.cos(e*t*1.028)/t)}};j.prototype.refresh=function(e){var r,i=!1;e===n?(i=!0,nt=[],vt=0,e=t.getElementsByTagName("*")):e=[].concat(e);for(r=0;r<e.length;r++){var s=e[r],o=s,l=[],c=ht;if(!s.attributes)continue;for(var h=0;h<s.attributes.length;h++){var p=s.attributes[h];if(p.name==="data-anchor-target"){o=t.querySelector(p.value);if(o===null)throw'Unable to find anchor target "'+p.value+'"';continue}if(p.name==="data-smooth-scrolling"){c=p.value!=="off";continue}var d=p.name.match(T);if(d!==null){var g=d[1];g=g&&ut[g.substr(1)]||0;var y=(d[2]|0)+g,b=d[3],S=d[4]||b,x={offset:y,props:p.value,element:s};l.push(x),!b||b===v||b===m?(x.mode="absolute",b===m?x.isEnd=!0:(x.frame=y*ot,delete x.offset)):(x.mode="relative",x.anchors=[b,S])}}if(l.length){var N,C,k;!i&&E in s?(k=s[E],N=nt[k].styleAttr,C=nt[k].classAttr):(k=s[E]=vt++,N=s.style.cssText,C=K(s));var L=nt[k]={element:s,styleAttr:N,classAttr:C,anchorTarget:o,keyFrames:l,smoothScrolling:c};Q(s,[f,u],[a]),L[w]=!0}}$();for(r=0;r<e.length;r++){var A=nt[e[r][E]];if(A===n)continue;A.keyFrames.sort(et),R(A),z(A)}return tt},j.prototype.relativeToAbsolute=function(e,t,n){var r=s.clientHeight,i=e.getBoundingClientRect(),o=i.top,u=i.bottom-i.top;return t===b?o-=r:t===y&&(o-=r/2),n===b?o+=u:n===y&&(o+=u/2),o+=tt.getScrollTop(),o+.5|0},j.prototype.animateTo=function(e,t){t=t||{};var r=Z(),i=tt.getScrollTop();return ct={startTop:i,topDiff:e-i,targetTop:e,duration:t.duration||p,startTime:r,endTime:r+(t.duration||p),easing:B[t.easing||h],done:t.done},ct.topDiff||(ct.done&&ct.done.call(tt,!1),ct=n),tt},j.prototype.stopAnimateTo=function(){ct&&ct.done&&ct.done.call(tt,!0),ct=n},j.prototype.isAnimatingTo=function(){return!!ct},j.prototype.setScrollTop=function(t){return r.iscroll?r.iscroll.scrollTo(0,-t):e.scrollTo(0,t),tt},j.prototype.getScrollTop=function(){return r.iscroll?-r.iscroll.y:e.pageYOffset||s.scrollTop||o.scrollTop||0},j.prototype.on=function(e,t){return rt[e]=t,tt},j.prototype.off=function(e){return delete rt[e],tt};var F=function(){var e,t,n,r,i,s,o,u,a;for(s=0;s<nt.length;s++){e=nt[s],t=e.element,n=e.anchorTarget,r=e.keyFrames;for(o=0;o<r.length;o++)i=r[o],i.mode==="relative"&&(u=t.style.cssText,a=K(t),t.style.cssText=e.styleAttr,Q(t,e.classAttr),i.frame=tt.relativeToAbsolute(n,i.anchors[0],i.anchors[1])-i.offset,t.style.cssText=u,Q(t,a)),it&&!i.isEnd&&i.frame>st&&(st=i.frame)}st=Math.max(st,J());for(s=0;s<nt.length;s++){e=nt[s],r=e.keyFrames;for(o=0;o<r.length;o++)i=r[o],i.isEnd&&(i.frame=st-i.offset)}},I=function(e,t){for(var n=0;n<nt.length;n++){var s=nt[n],o=s.smoothScrolling?e:t,f=s.keyFrames,l=f[0].frame,c=f[f.length-1].frame,h=o<=l,p=o>=c,d,v;if(h||p){var m=f[h?0:f.length-1].props;for(d in m)i.call(m,d)&&(v=V(m[d].value),r.setStyle(s.element,d,v));s[w]&&(o<l||o>c)&&(Q(s.element,[a],[u]),s[w]=!1);continue}s[w]||(Q(s.element,[u],[a]),s[w]=!0);for(var g=0;g<f.length-1;g++)if(o>=f[g].frame&&o<=f[g+1].frame){var y=f[g],b=f[g+1];for(d in y.props)if(i.call(y.props,d)){var E=(o-y.frame)/(b.frame-y.frame);E=y.props[d].easing(E),v=X(y.props[d].value,b.props[d].value,E),v=V(v),r.setStyle(s.element,d,v)}break}}},q=function(){var e=tt.getScrollTop(),t,r=Z(),i;if(ct)r>=ct.endTime?(e=ct.targetTop,t=ct.done,ct=n):(i=ct.easing((r-ct.startTime)/ct.duration),e=ct.startTop+i*ct.topDiff|0),tt.setScrollTop(e);else{var s=pt.targetTop-e;s&&(pt={startTop:ft,topDiff:e-ft,targetTop:e,startTime:lt,endTime:lt+d}),r<=pt.endTime&&(i=B.sqrt((r-pt.startTime)/d),e=pt.startTop+i*pt.topDiff|0)}e<0&&(e=0);if(dt||ft!==e){at=e>=ft?"down":"up",dt=!1;var o={curTop:e,lastTop:ft,maxTop:st,direction:at},u=rt.beforerender&&rt.beforerender.call(tt,o);u!==!1&&(I(e,tt.getScrollTop()),ft=e,rt.render&&rt.render.call(tt,o)),t&&t.call(tt,!1)}lt=r},R=function(e){for(var t=0;t<e.keyFrames.length;t++){var n=e.keyFrames[t],r,i,s,o={},u;while((u=N.exec(n.props))!==null)s=u[1],i=u[2],r=s.match(C),r!==null?(s=r[1],r=r[2]):r=h,i=i.indexOf("!")?U(i):[i.slice(1)],o[s]={value:i,easing:B[r]};n.props=o}},U=function(e){var t=[];return M.lastIndex=0,e=e.replace(M,function(e){return e.replace(A,function(e){return e/255*100+"%"})}),P&&(_.lastIndex=0,e=e.replace(_,function(e){return P+e})),e=e.replace(A,function(e){return t.push(+e),"{?}"}),t.unshift(e),t},z=function(e){var t={},n;for(n=0;n<e.keyFrames.length;n++)W(e.keyFrames[n],t);t={};for(n=e.keyFrames.length-1;n>=0;n--)W(e.keyFrames[n],t)},W=function(e,t){var n;for(n in t)i.call(e.props,n)||(e.props[n]=t[n]);for(n in e.props)t[n]=e.props[n]},X=function(e,t,n){if(e.length!==t.length)throw"Can't interpolate between \""+e[0]+'" and "'+t[0]+'"';var r=[e[0]];for(var i=1;i<e.length;i++)r[i]=e[i]+(t[i]-e[i])*n;return r},V=function(e){var t=1;return O.lastIndex=0,e[0].replace(O,function(){return e[t++]})};r.setStyle=function(e,t,n){var r=e.style;t=t.replace(k,L).replace("-","");if(t==="zIndex")r[t]=""+(n|0);else if(t==="float")r.styleFloat=r.cssFloat=n;else try{D&&(r[D+t.slice(0,1).toUpperCase()+t.slice(1)]=n),r[t]=n}catch(i){}},r.addEvent=function(t,n,r){var i=function(t){return t=t||e.event,t.target||(t.target=t.srcElement),t.preventDefault||(t.preventDefault=function(){t.returnValue=!1}),r.call(this,t)};e.addEventListener?t.addEventListener(n,i,!1):t.attachEvent("on"+n,i)};var $=function(){st=0,F(),dt=!0,r.iscroll&&e.setTimeout(function(){r.iscroll.refresh()},0)},J=function(){var e=Math.max(o.scrollHeight,o.offsetHeight,s.scrollHeight,s.offsetHeight,s.clientHeight);return e-s.clientHeight},K=function(t){var n="className";return e.SVGElement&&t instanceof e.SVGElement&&(t=t[n],n="baseVal"),t[n]},Q=function(t,r,i){var s="className";e.SVGElement&&t instanceof e.SVGElement&&(t=t[s],s="baseVal");if(i===n){t[s]=r;return}var o=t[s];for(var u=0;u<r.length;u++)Y(o).indexOf(Y(r[u]))===-1&&(o+=" "+r[u]);for(var a=0;a<i.length;a++)o=Y(o).replace(Y(i[a])," ");t[s]=G(o)},G=function(e){return e.replace(x,"$1")},Y=function(e){return" "+e+" "},Z=Date.now||function(){return+(new Date)},et=function(e,t){return e.frame-t.frame},tt,nt,rt,it,st=0,ot=1,ut,at="down",ft=-1,lt=Z(),ct,ht,pt,dt,vt=0})(window,document);
+(function(e,t,n){"use strict";function j(n){s=t.documentElement,o=t.body,H(),tt=this,n=n||{},ut=n.constants||{};if(n.easing)for(var i in n.easing)B[i]=n.easing[i];rt={beforerender:n.beforerender,render:n.render},it=n.forceHeight!==!1,ht=n.smoothScrolling!==!1,pt={targetTop:tt.getScrollTop()},it&&(ot=n.scale||1),Q(s,[l],[c]);if(it){var u=t.getElementById("skrollr-body")||t.createElement("div"),a=u.style;a.minWidth="1px",a.position="absolute",a.top=a.zIndex="0",u.id||(a.width="1px",a.right="0",o.appendChild(u)),function(e){$=function(){e.apply(this,arguments),a.height=st+s.clientHeight+"px"}}($)}return tt.refresh(),r.addEvent(e,"resize",$),function f(){S(f),q()}(),tt}var r=e.skrollr={get:function(){return tt},init:function(e){return tt||new j(e)},VERSION:"0.5.14"},i=Object.prototype.hasOwnProperty,s,o,u="rendered",a="un"+u,f="skrollable",l="skrollr",c="no-"+l,h="linear",p=1e3,d=200,v="start",m="end",g="top",y="center",b="bottom",w="___has_rendered_class",E="___skrollable_id",S=e.requestAnimationFrame;(function(){var t=["ms","moz","webkit","o"],n;for(n=0;n<t.length&&!S;n++)S=e[t[n]+"RequestAnimationFrame"];var r=0;S||(S=function(t){var n=Z(),i=Math.max(0,30-(n-r));e.setTimeout(function(){t(n+i)},i),r=n+i})})();var x=/^\s*(.+)\s*$/m,T=/^data(?:-(_\w+))?(?:-?(-?\d+))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/,N=/\s*([a-z\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,C=/^([a-z\-]+)\[(\w+)\]$/,k=/-([a-z])/g,L=function(e,t){return t.toUpperCase()},A=/[\-+]?[\d]*\.?[\d]+/g,O=/\{\?\}/g,M=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,_=/[a-z\-]+-gradient/g,D,P,H=function(){var t=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;if(e.getComputedStyle){var n=e.getComputedStyle(o,null);for(var r in n){D=r.match(t)||+r==r&&n[r].match(t);if(D)break}D&&(D=D[0],D.slice(0,1)==="-"?(P=D,D={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[D]):P="-"+D.toLowerCase()+"-")}},B={begin:function(){return 0},end:function(){return 1},linear:function(e){return e},quadratic:function(e){return e*e},cubic:function(e){return e*e*e},swing:function(e){return-Math.cos(e*Math.PI)/2+.5},sqrt:function(e){return Math.sqrt(e)},bounce:function(e){var t;if(e<=.5083)t=3;else if(e<=.8489)t=9;else if(e<=.96208)t=27;else{if(!(e<=.99981))return 1;t=91}return 1-Math.abs(3*Math.cos(e*t*1.028)/t)}};j.prototype.refresh=function(e){var r,i=!1;e===n?(i=!0,nt=[],vt=0,e=t.getElementsByTagName("*")):e=[].concat(e);for(r=0;r<e.length;r++){var s=e[r],o=s,l=[],c=ht;if(!s.attributes)continue;for(var h=0;h<s.attributes.length;h++){var p=s.attributes[h];if(p.name==="data-anchor-target"){o=t.querySelector(p.value);if(o===null)throw'Unable to find anchor target "'+p.value+'"';continue}if(p.name==="data-smooth-scrolling"){c=p.value!=="off";continue}var d=p.name.match(T);if(d!==null){var g=d[1];g=g&&ut[g.substr(1)]||0;var y=(d[2]|0)+g,b=d[3],S=d[4]||b,x={offset:y,props:p.value,element:s};l.push(x),!b||b===v||b===m?(x.mode="absolute",b===m?x.isEnd=!0:(x.frame=y*ot,delete x.offset)):(x.mode="relative",x.anchors=[b,S])}}if(l.length){var N,C,k;!i&&E in s?(k=s[E],N=nt[k].styleAttr,C=nt[k].classAttr):(k=s[E]=vt++,N=s.style.cssText,C=K(s));var L=nt[k]={element:s,styleAttr:N,classAttr:C,anchorTarget:o,keyFrames:l,smoothScrolling:c};Q(s,[f,u],[a]),L[w]=!0}}$();for(r=0;r<e.length;r++){var A=nt[e[r][E]];if(A===n)continue;A.keyFrames.sort(et),R(A),z(A)}return tt},j.prototype.relativeToAbsolute=function(e,t,n){var r=s.clientHeight,i=e.getBoundingClientRect(),o=i.top,u=i.bottom-i.top;return t===b?o-=r:t===y&&(o-=r/2),n===b?o+=u:n===y&&(o+=u/2),o+=tt.getScrollTop(),o+.5|0},j.prototype.animateTo=function(e,t){t=t||{};var r=Z(),i=tt.getScrollTop();return ct={startTop:i,topDiff:e-i,targetTop:e,duration:t.duration||p,startTime:r,endTime:r+(t.duration||p),easing:B[t.easing||h],done:t.done},ct.topDiff||(ct.done&&ct.done.call(tt,!1),ct=n),tt},j.prototype.stopAnimateTo=function(){ct&&ct.done&&ct.done.call(tt,!0),ct=n},j.prototype.isAnimatingTo=function(){return!!ct},j.prototype.setScrollTop=function(t,n){return n===!0&&(ft=t,dt=!0),r.iscroll?r.iscroll.scrollTo(0,-t):e.scrollTo(0,t),tt},j.prototype.getScrollTop=function(){return r.iscroll?-r.iscroll.y:e.pageYOffset||s.scrollTop||o.scrollTop||0},j.prototype.on=function(e,t){return rt[e]=t,tt},j.prototype.off=function(e){return delete rt[e],tt};var F=function(){var e,t,n,r,i,s,o,u,a;for(s=0;s<nt.length;s++){e=nt[s],t=e.element,n=e.anchorTarget,r=e.keyFrames;for(o=0;o<r.length;o++)i=r[o],i.mode==="relative"&&(u=t.style.cssText,a=K(t),t.style.cssText=e.styleAttr,Q(t,e.classAttr),i.frame=tt.relativeToAbsolute(n,i.anchors[0],i.anchors[1])-i.offset,t.style.cssText=u,Q(t,a)),it&&!i.isEnd&&i.frame>st&&(st=i.frame)}st=Math.max(st,J());for(s=0;s<nt.length;s++){e=nt[s],r=e.keyFrames;for(o=0;o<r.length;o++)i=r[o],i.isEnd&&(i.frame=st-i.offset)}},I=function(e,t){for(var n=0;n<nt.length;n++){var s=nt[n],o=s.smoothScrolling?e:t,f=s.keyFrames,l=f[0].frame,c=f[f.length-1].frame,h=o<=l,p=o>=c,d,v;if(h||p){var m=f[h?0:f.length-1].props;for(d in m)i.call(m,d)&&(v=V(m[d].value),r.setStyle(s.element,d,v));s[w]&&(o<l||o>c)&&(Q(s.element,[a],[u]),s[w]=!1);continue}s[w]||(Q(s.element,[u],[a]),s[w]=!0);for(var g=0;g<f.length-1;g++)if(o>=f[g].frame&&o<=f[g+1].frame){var y=f[g],b=f[g+1];for(d in y.props)if(i.call(y.props,d)){var E=(o-y.frame)/(b.frame-y.frame);E=y.props[d].easing(E),v=X(y.props[d].value,b.props[d].value,E),v=V(v),r.setStyle(s.element,d,v)}break}}},q=function(){var e=tt.getScrollTop(),t,r=Z(),i;if(ct)r>=ct.endTime?(e=ct.targetTop,t=ct.done,ct=n):(i=ct.easing((r-ct.startTime)/ct.duration),e=ct.startTop+i*ct.topDiff|0),tt.setScrollTop(e);else{var s=pt.targetTop-e;s&&(pt={startTop:ft,topDiff:e-ft,targetTop:e,startTime:lt,endTime:lt+d}),r<=pt.endTime&&(i=B.sqrt((r-pt.startTime)/d),e=pt.startTop+i*pt.topDiff|0)}e<0&&(e=0);if(dt||ft!==e){at=e>=ft?"down":"up",dt=!1;var o={curTop:e,lastTop:ft,maxTop:st,direction:at},u=rt.beforerender&&rt.beforerender.call(tt,o);u!==!1&&(I(e,tt.getScrollTop()),ft=e,rt.render&&rt.render.call(tt,o)),t&&t.call(tt,!1)}lt=r},R=function(e){for(var t=0;t<e.keyFrames.length;t++){var n=e.keyFrames[t],r,i,s,o={},u;while((u=N.exec(n.props))!==null)s=u[1],i=u[2],r=s.match(C),r!==null?(s=r[1],r=r[2]):r=h,i=i.indexOf("!")?U(i):[i.slice(1)],o[s]={value:i,easing:B[r]};n.props=o}},U=function(e){var t=[];return M.lastIndex=0,e=e.replace(M,function(e){return e.replace(A,function(e){return e/255*100+"%"})}),P&&(_.lastIndex=0,e=e.replace(_,function(e){return P+e})),e=e.replace(A,function(e){return t.push(+e),"{?}"}),t.unshift(e),t},z=function(e){var t={},n;for(n=0;n<e.keyFrames.length;n++)W(e.keyFrames[n],t);t={};for(n=e.keyFrames.length-1;n>=0;n--)W(e.keyFrames[n],t)},W=function(e,t){var n;for(n in t)i.call(e.props,n)||(e.props[n]=t[n]);for(n in e.props)t[n]=e.props[n]},X=function(e,t,n){if(e.length!==t.length)throw"Can't interpolate between \""+e[0]+'" and "'+t[0]+'"';var r=[e[0]];for(var i=1;i<e.length;i++)r[i]=e[i]+(t[i]-e[i])*n;return r},V=function(e){var t=1;return O.lastIndex=0,e[0].replace(O,function(){return e[t++]})};r.setStyle=function(e,t,n){var r=e.style;t=t.replace(k,L).replace("-","");if(t==="zIndex")r[t]=""+(n|0);else if(t==="float")r.styleFloat=r.cssFloat=n;else try{D&&(r[D+t.slice(0,1).toUpperCase()+t.slice(1)]=n),r[t]=n}catch(i){}},r.addEvent=function(t,n,r){var i=function(t){return t=t||e.event,t.target||(t.target=t.srcElement),t.preventDefault||(t.preventDefault=function(){t.returnValue=!1}),r.call(this,t)};e.addEventListener?t.addEventListener(n,i,!1):t.attachEvent("on"+n,i)};var $=function(){st=0,F(),dt=!0,r.iscroll&&e.setTimeout(function(){r.iscroll.refresh()},0)},J=function(){var e=Math.max(o.scrollHeight,o.offsetHeight,s.scrollHeight,s.offsetHeight,s.clientHeight);return e-s.clientHeight},K=function(t){var n="className";return e.SVGElement&&t instanceof e.SVGElement&&(t=t[n],n="baseVal"),t[n]},Q=function(t,r,i){var s="className";e.SVGElement&&t instanceof e.SVGElement&&(t=t[s],s="baseVal");if(i===n){t[s]=r;return}var o=t[s];for(var u=0;u<r.length;u++)Y(o).indexOf(Y(r[u]))===-1&&(o+=" "+r[u]);for(var a=0;a<i.length;a++)o=Y(o).replace(Y(i[a])," ");t[s]=G(o)},G=function(e){return e.replace(x,"$1")},Y=function(e){return" "+e+" "},Z=Date.now||function(){return+(new Date)},et=function(e,t){return e.frame-t.frame},tt,nt,rt,it,st=0,ot=1,ut,at="down",ft=-1,lt=Z(),ct,ht,pt,dt,vt=0})(window,document);
View
2  examples/circular_motion.html
@@ -34,7 +34,7 @@
render: function(data) {
//Loop
if(data.curTop === data.maxTop) {
- this.setScrollTop(0);
+ this.setScrollTop(0, true);
}
}
});
View
8 src/skrollr.js
@@ -527,7 +527,13 @@
return !!_scrollAnimation;
};
- Skrollr.prototype.setScrollTop = function(top) {
+ Skrollr.prototype.setScrollTop = function(top, force) {
+ //Don't do smooth scrolling (last top === new top).
+ if(force === true) {
+ _lastTop = top;
+ _forceRender = true;
+ }
+
//skrollr.iscroll is an instance of iscroll available in mobile mode
if(skrollr.iscroll) {
//Notice the minus.
Please sign in to comment.
Something went wrong with that request. Please try again.