Skip to content

Instantly share code, notes, and snippets.

@baxtheman
Created March 28, 2014 08:44
Show Gist options
  • Save baxtheman/9828154 to your computer and use it in GitHub Desktop.
Save baxtheman/9828154 to your computer and use it in GitHub Desktop.
anim
<aui:script use="aui-base,anim-base,anim-node-plugin,anim-scroll">
var step = 25;
var scrolling = false;
var list = A.one('.oneshop-portlet-item-browser .list');
var a = new A.Anim({
node: '.oneshop-portlet-item-browser .list',
duration: 0.5
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-up').on('mouseenter', function() {
scrolling = true;
scrollContent("up");
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-up').on('mouseleave', function() {
a.stop();
scrolling = false;
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-down').on('mouseenter', function() {
scrolling = true;
scrollContent("down");
});
A.one('.oneshop-portlet-item-browser .btn.icon-chevron-down').on('mouseleave', function() {
a.stop();
scrolling = false;
});
function scrollContent(direction) {
var amount = (direction === "up" ? -100 : +100);
console.log(direction);
a.set('to',{
scrollTop: list.attr('scrollTop') + amount
});
a.on('end', function() {
if (scrolling) {
console.log("again");
scrollContent(direction);
}
});
a.run();
}
</aui:script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment