UNPKG

@nutui/nutui-react

Version:

京东风格的轻量级移动端 React 组件库,支持一套代码生成 H5 和小程序

29 lines (28 loc) 1.11 kB
export var momentum = function(distance, duration) { var speed = Math.abs(distance / duration); return speed / 0.003 * (distance < 0 ? -1 : 1); }; export var useStyles = function(touchTime, touchDeg, scrollDistance, lineSpacing, rotation) { var getTransitionStyle = function(transformValue) { return { transition: "transform ".concat(touchTime, "ms cubic-bezier(0.17, 0.89, 0.45, 1)"), transform: transformValue }; }; var touchRollerStyle = function() { return getTransitionStyle("rotate3d(1, 0, 0, ".concat(touchDeg, ")")); }; var touchTiledStyle = function() { return getTransitionStyle("translate3d(0, ".concat(scrollDistance, "px, 0)")); }; var rollerStyle = function(index) { return { transform: "rotate3d(1, 0, 0, ".concat(-rotation * (index + 1), "deg) translate3d(0px, 0px, ").concat(Math.round(lineSpacing.current * 3.2), "px)") }; }; return { touchRollerStyle: touchRollerStyle, touchTiledStyle: touchTiledStyle, rollerStyle: rollerStyle }; };