简体   繁体   English

我如何使用javascript在类似IOS Picker视图的对象上创建轻拂的“ momemtum效果”

[英]how can i create a flick “momemtum effect” on an object like IOS picker view using javascript

http://codepen.io/PageOnline/pen/Lkdue http://codepen.io/PageOnline/pen/Lddue

the link above is to a "safe" type combo lock when you click on one of the numbers it moves to the next. 当您单击一个数字时,上面的链接是一个“安全”类型的组合锁。 (as expected). (如预期)。 I am trying to re-create this but instead use a "flick" motion to be able to spin it using ccs 3 rotate z. 我正在尝试重新创建它,而是使用“轻拂”动作来使用ccs 3旋转z使其旋转。 the problem is i cannot find any examples or "stack" questions that address momentum and inertia that don't involve canvas. 问题是我找不到涉及画布的动量和惯性的任何示例或“堆栈”问题。 is there any other way to be able to "flick" the numbers so they spin and slow down and eventually stop? 还有其他方法可以“拂动”数字,使它们旋转并减速并最终停止吗? kind of like IOS pickers? 有点像IOS选择器?

thanks in advance. 提前致谢。

You could use the keyframes for the speeding up and slowing down part. 您可以使用关键帧来加快和降低部分速度。 That's the most I can do for you. 那是我能为您做的最大的事情。 http://jsfiddle.net/p8GWT/ http://jsfiddle.net/p8GWT/

    #logo:hover{
  -webkit-animation-name: rotateThis;
  -webkit-animation-duration:2s;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function:ease-in-out;

  -moz-animation-name: rotateThis;
  -moz-animation-duration:2s;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function:ease-in-out;

  -ms-animation-name: rotateThis;
  -ms-animation-duration:2s;
  -ms-animation-iteration-count: 1;
  -ms-animation-timing-function:ease-in-out;

  animation-name: rotateThis;
  animation-duration:2s;
  animation-iteration-count: 1;
  animation-timing-function:ease-in-out;
}
@-webkit-keyframes rotateThis {
    0% { -webkit-transform:scale(1) rotate(0deg); }
    10% { -webkit-transform:scale(1.1) rotate(0deg); }
    90% {-webkit-transform:scale(1.1) rotate(360deg);}
    100% { -webkit-transform:scale(1) rotate(360deg); }
}
@-moz-keyframes rotateThis {
    0% { -moz-transform:scale(1) rotate(0deg); }
    10% { -moz-transform:scale(1.1) rotate(0deg); }
    90% {-moz-transform:scale(1.1) rotate(360deg);}
    100% { -moz-transform:scale(1) rotate(360deg); }
}
@-ms-keyframes rotateThis {
    0% { -ms-transform:scale(1) rotate(0deg); }
    10% { -ms-transform:scale(1.1) rotate(0deg); }
    90% {-ms-transform:scale(1.1) rotate(360deg);}
    100% { -ms-transform:scale(1) rotate(360deg); }
}
@keyframes rotateThis {
    0% { transform:scale(1) rotate(0deg); }
    10% { transform:scale(1.1) rotate(0deg); }
    90% { transform:scale(1.1) rotate(360deg);}
    100% { transform:scale(1) rotate(360deg); }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM