プロジェクト
GitHubで見る
PixelsCommander/Propeller
概要
マウスやタッチジェスチャーで要素を回転させるJavaScriptライブラリです。慣性回転と段階的な回転に対応し、パフォーマンスを高めるよう最適化されています。
開発ツール計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナル![]()
JavaScript library to rotate elements by mouse. Supports inertia and stepwise rotation. It is also compatible with touch devices.
Spinner game drawn by my doughter
![]()
Usage
Available on NPM
npm install Propeller
Easy-to-use as jQuery plugin:
$(nodeOrSelector).propeller(options);
or zero-dependancy library
new Propeller(nodeOrSelector, options)
Performance
Propeller uses requestAnimationFrame and GPU compositing for better performance.
Options
- angle sets initial angle
- inertia is the most valueble option. It is a number between 0 and 1. 0 means no rotation after mouse was released. 1 means infinite rotation. For this demo we use inertia equals to 0.99.
- speed - initial speed of rotation. It also can be used as property in runtime.
- minimalSpeed - minimal speed of rotation. Works only if propeller have inertia between 0 and 1.
- step allows to set step in degrees for stepwise mode.
- stepTransitionTime enables CSS transition to move from step to step. This makes steps smooth and allows to use CSS transitions easing.
- stepTransitionEasing CSS easing mode for transition when in stepwise mode and stepTransitionTime is more than zero. A bit more about easing functions
- onRotate callback executed when rotated. You can easily get current angle as this.angle inside of callback function.
- onStop callback executed when stopped.
- onDragStart callback executed when start dragging.
- onDragStop callback executed when stop dragging.
Methods
- unbind unbind listeners to make propeller inactive, this does not stop rotation
- bind bind listeners after they were unbinded
- stop stop rotation immidiately
Public properties
- angle current propellers angle.
- speed current speed of rotation. Degrees per frame.
License
Copyright 2014 Denis Radin aka PixelsCommander
関連プロジェクトを探す
読み込み中…