#153 new
Ed Sanders

Duration for revert effect is calculated incorrectly

Reported by Ed Sanders | January 8th, 2009 @ 04:41 PM

Line 232 of dragdrop.jd tries to square a number using "^2" with is is the bitwise xor operator, instead of Math.pow(x,2). This means the current calculation is approximately:

Math.sqrt(top_offset + left_offset) * 0.02

(give or take a bit of wobble caused by the xor operation)

This means the duration of the effect if proportionate to the square root of the "Manhattan" distance of the displacement.

Presumably the author intended:

Math.sqrt(Math.pow(top_offset, 2) + Math.pow(left_offset, 2)) * 0.02

Which would make the duration proportionate to the diagonal distance of the drag, making the revert speed constant.

There are three possible fixes: 1. Use the sqrt(a^2 + b^2) * k (with a new constant that provides a suitable speed). However this will change the "feel" of the effect, as long drags will revert at the same speed as small drags, whereas currently they are faster. 2. Use sqrt(sqrt(a^2 + b^2)) * k to preserve the distance-speed relationship. I recommend this option. 3. Continue to use the "Manhattan" distance, in which case we should at least remove the "^2"s.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

script.aculo.us is an open-source JavaScript framework for visual effects and interface behaviours.
<br/><b>Source available from github</b>
The Git repository resides at:
<a href="http://github.com/madrobby/scriptaculous">http://github.com/madrobby/scriptaculous</a>
<br/>Check out the current development trunk with:
<code>git clone git://github.com/madrobby/scriptaculous.git</code>
<br/>As <b>script.aculo.us 1.xx is feature-frozen</b>, this development trunk is for <b>bugfixes only</b>.
<br/>New development should happen only for
<b>script.aculo.us 2</b>.
<br/><b>Creating a bug report</b>
When creating a bug report, be sure to include as much relevant information as possible. Post a an example that shows off the problem. Preferably, <b>alter the unit tests</b> and show through either changed or added tests how the expected behavior is not occuring.

People watching this ticket

Pages