[英]Animate scrollLeft in angularjs
So I am trying to animate the scrollLeft property on an element I get from the $event
.所以我试图为从
$event
获得的元素上的 scrollLeft 属性设置动画。 I can set the scrollLeft easily but it doesn't animate.我可以轻松设置 scrollLeft 但它没有动画。 So I tried adding the
animate()
method to it and its no longer scrolling.所以我尝试向它添加
animate()
方法并且它不再滚动。 Is there something I am missing here?有什么我在这里想念的吗?
The function:功能:
vm.scrollChipsContainer = function (event, direction) {
var element = event.target.parentElement;
var scrollPos = element.scrollLeft;
switch (direction) {
case 'right':
event.target.parentElement.animate({scrollLeft: scrollPos + 100}, 100);
break;
case 'left':
event.target.parentElement.animate({scrollLeft: scrollPos - 100}, 100);
break;
default:
break;
}
};
Use用
element.scrollTo({
left: your_value,
behavior: 'smooth'
});
https://stackblitz.com/edit/angular-wo2imk https://stackblitz.com/edit/angular-wo2imk
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.