Skip to content

Commit

Permalink
more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kingdido999 committed Dec 31, 2016
1 parent 76fec92 commit a322701
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 10 deletions.
21 changes: 18 additions & 3 deletions build/zooming.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/zooming.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/zooming.min.js.map

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,36 @@ <h3 class='mb0 no-anchor'></h3>

</li>


<li><a
href='#press_delay'
class="">
PRESS_DELAY

</a>

</li>


<li><a
href='#event_types_grab'
class="">
EVENT_TYPES_GRAB

</a>

</li>


<li><a
href='#multitouch_scale_factor'
class="">
MULTITOUCH_SCALE_FACTOR

</a>

</li>

</ul>
</div>
<div class='mt1 h6 quiet'>
Expand Down Expand Up @@ -1776,6 +1806,155 @@ <h3 class='fl m0' id='options'>
</div>






</section>




<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='press_delay'>
PRESS_DELAY
</h3>


</div>


<p>Duration (ms) longer than or equal to this value will be recognized as grab,
otherwise click.</p>


<div class='pre p1 fill-light mt0'>PRESS_DELAY</div>

<p>
Type:
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>
</p>
























</section>




<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='event_types_grab'>
EVENT_TYPES_GRAB
</h3>


</div>


<p>Event types related to grab.</p>


<div class='pre p1 fill-light mt0'>EVENT_TYPES_GRAB</div>
























</section>




<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='multitouch_scale_factor'>
MULTITOUCH_SCALE_FACTOR
</h3>


</div>


<p>Scale factor for multi-touch.</p>


<div class='pre p1 fill-light mt0'>MULTITOUCH_SCALE_FACTOR</div>

<p>
Type:
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>
</p>























Expand Down
6 changes: 3 additions & 3 deletions src/EventHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { scrollTop, bind } from './_helpers'
import { PRESS_DELAY, TOUCH_SCALE_FACTOR } from './_defaults'
import { PRESS_DELAY, MULTITOUCH_SCALE_FACTOR } from './_defaults'

export default class EventHandler {

Expand Down Expand Up @@ -131,9 +131,9 @@ function processTouches (touches, currScaleExtra, cb) {
const [distX, distY] = [max.x - min.x, max.y - min.y]

if (distX > distY) {
scaleExtra = (distX / window.innerWidth) * TOUCH_SCALE_FACTOR
scaleExtra = (distX / window.innerWidth) * MULTITOUCH_SCALE_FACTOR
} else {
scaleExtra = (distY / window.innerHeight) * TOUCH_SCALE_FACTOR
scaleExtra = (distY / window.innerHeight) * MULTITOUCH_SCALE_FACTOR
}
}

Expand Down
19 changes: 17 additions & 2 deletions src/_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,31 @@ const OPTIONS = {
onBeforeRelease: null
}

/**
* Duration (ms) longer than or equal to this value will be recognized as grab,
* otherwise click.
* @type {number}
*/
const PRESS_DELAY = 200

/**
* Event types related to grab.
* @type {Array}
*/
const EVENT_TYPES_GRAB = [
'mousedown', 'mousemove', 'mouseup',
'touchstart', 'touchmove', 'touchend'
]
const TOUCH_SCALE_FACTOR = 2

/**
* Scale factor for multi-touch.
* @type {number}
*/
const MULTITOUCH_SCALE_FACTOR = 2

export {
OPTIONS,
PRESS_DELAY,
EVENT_TYPES_GRAB,
TOUCH_SCALE_FACTOR
MULTITOUCH_SCALE_FACTOR
}

0 comments on commit a322701

Please sign in to comment.