Comparing version 2.0.0 to 2.0.1
99
API.md
@@ -9,67 +9,98 @@ # Easing | ||
This creates a new object from which to do easing transitions. | ||
**Returns** an easey object, which has the following methods: | ||
### ease.from(MM.Coordinate) | ||
### ease.from(coord) | ||
Set the 'from' coordinate in this easing. The map starts from here. You don't usually need to call this, because calling `.map(mapObject)` automatically assigns `from` to the current position of the map: | ||
Set the starting coordinate for the easing. You don't usually need to call this, because easings default to the current coordinate. | ||
from = map.coordinate.copy(); | ||
**Arguments:** | ||
### ease.to(MM.Coordinate) | ||
* `coord` is an instance of `MM.Coordinate` representing the starting coordinate for the easing. | ||
Set the destination of the ease: this takes `MM.Coordinate`s - you can get coordinates out of other types by using `locationCoordinate` and `pointCoordinate`. | ||
**Returns** the easey object. | ||
### ease.to(coord) | ||
Set the destination coordinate for the easing. | ||
**Arguments:** | ||
* `coord` is an instance of `MM.Coordinate` representing the destination coordinate for the easing. | ||
Since easey deals exclusively in Coordinates, [the reference for converting between points, locations, and coordinates in Modest Maps is essential reading](https://github.com/stamen/modestmaps-js/wiki/Point,-Location,-and-Coordinate). | ||
### ease.zoom(value) | ||
**Returns** the easey object. | ||
Set the zoom level of the `to` coordinate, so the zoom level that easey is easing to. The argument to this | ||
function must be a number corresponding to a zoom level. | ||
### ease.zoom(level) | ||
This is a convenience function for | ||
Set the zoom level of the `to` coordinate that easey is easing to. | ||
easey.to(easey.to().zoomTo(zoomLevel)); | ||
**Arguments:** | ||
* `level` is a number representing the zoom level | ||
**Returns** the easey object. | ||
### ease.t(value) | ||
Derive a point in the ease. The argument is a float between 0 and 1, in which 0 is `from` and 1 is `to`. | ||
Set the map to a specific point in the easing. | ||
### ease.future(value) | ||
**Arguments:** | ||
Get the future of an easing transition, given a number of parts for it to be divided over. | ||
This returns an array of `MM.Coordinate` objects representing each in-between location. | ||
The argument to this function is a positive integer number. | ||
* `value` is a float between 0 and 1, where 0 is `from` and 1 is `to`. | ||
This is a convenience function for calling `easey.t()` a bunch of times. | ||
**Returns** the easey object. | ||
### ease.easing(value) | ||
### ease.future(parts) | ||
Set the easing curve. This takes a string as its argument. The current options are: | ||
Get the future of an easing transition, given a number of parts for it to be divided over. This is a convenience function for calling `easey.t()` a bunch of times. | ||
* 'easeIn' | ||
* 'easeOut' | ||
* 'easeInOut' | ||
* 'linear' | ||
**Arguments:** | ||
### ease.path(value) | ||
* `parts` is an positive integer representing the number of parts to divide the easing into. | ||
**Returns** an array of `MM.Coordinate` objects representing each in-between location. | ||
### ease.easing(name) | ||
Set the easing curve - this defines how quickly the transition gets to its end and whether it speeds up or slows down near the beginning | ||
and end. | ||
**Arguments:** | ||
* `name` is the string name of the easing to use. Current options are: | ||
* 'easeIn' | ||
* 'easeOut' | ||
* 'easeInOut' | ||
* 'linear' | ||
**Returns** the easey object. | ||
### ease.path(pathname) | ||
Set the type of path - the type of interpolation between points. | ||
This takes a string with the current options: | ||
**Arguments:** | ||
* `screen`: a 'straight line' path from place to place - in the Mercator projection, this is a rhumb line | ||
* `about`: the default path for a double-click zoom: this keeps a single coordinate in the same screen pixel over the zoom transition | ||
* `pathname` is a string name of the path to use. Current options are: | ||
* `screen`: a 'straight line' path from place to place - in the Mercator projection, this is a rhumb line | ||
* `about`: the default path for a double-click zoom: this keeps a single coordinate in the same screen pixel over the zoom transition | ||
**Returns** the easey object. | ||
### ease.run([time [, callback]) | ||
Start an _animated ease_. Both parameters are optional: if provided, `time` is | ||
an integer number corresponding to the number of milliseconds duration, | ||
and second argument is a `callback` - a Javascript function that | ||
is called when the map has moved to its destination. | ||
Start an _animated ease_. Both parameters are optional. | ||
Tile will default to `1000` and is measured in milliseconds. | ||
**Arguments:** | ||
* `time` is an integer representing the duration of the easing in milliseconds (default is 1000). | ||
* `callback` is a Javascript function that is called when the map has reached its destination. | ||
**Returns** the easey object. | ||
### var isRunning = ease.running() | ||
Returns `true` or `false` depending on whether easey is currently animating the map. | ||
**Returns** `true` or `false` depending on whether easey is currently animating the map. | ||
@@ -79,1 +110,3 @@ ### ease.stop() | ||
Abort the currently running animation. | ||
**Returns** the easey object. |
@@ -10,6 +10,6 @@ var map; | ||
new wax.mm.connector(tj), null, [ | ||
easey.DragHandler(), | ||
easey.TouchHandler(), | ||
easey.MouseWheelHandler(), | ||
easey.DoubleClickHandler() | ||
easey_handlers.DragHandler(), | ||
easey_handlers.TouchHandler(), | ||
easey_handlers.MouseWheelHandler(), | ||
easey_handlers.DoubleClickHandler() | ||
]); | ||
@@ -30,3 +30,2 @@ map.setCenterZoom(new com.modestmaps.Location(-10, 50), 3); | ||
var scrolly = document.getElementById('scrolly'); | ||
@@ -33,0 +32,0 @@ |
{ | ||
"name": "easey", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Easing for Modest Maps", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -40,2 +40,3 @@ ;(function(context, MM) { | ||
easey.zoom = function(x) { | ||
if (!to) to = map.coordinate.copy(); | ||
to = map.enforceZoomLimits(to.zoomTo(x)); | ||
@@ -75,3 +76,2 @@ return easey; | ||
map = x; | ||
to = map.coordinate.copy(); | ||
return easey; | ||
@@ -156,7 +156,5 @@ }; | ||
if (!from) from = map.coordinate.copy(); | ||
if (!to) to = map.coordinate.copy(); | ||
time = time || 1000; | ||
start = (+new Date()); | ||
running = true; | ||
@@ -169,7 +167,7 @@ | ||
abortCallback(); | ||
return abortCallback = undefined; | ||
return (abortCallback = undefined); | ||
} else if (delta > time) { | ||
running = false; | ||
map.coordinate = path(from, to, 1); | ||
from = undefined; | ||
to = from = undefined; | ||
map.draw(); | ||
@@ -176,0 +174,0 @@ if (callback) return callback(map); |
@@ -19,8 +19,2 @@ describe("Easey", function() { | ||
it('automatically sets to', function() { | ||
var ease = easey(); | ||
ease.map(map); | ||
expect(ease.to()).toEqual(map.coordinate); | ||
}); | ||
it('zooms the to coordinate with zoom()', function() { | ||
@@ -35,6 +29,6 @@ var ease = easey(); | ||
easey().map(map) | ||
.from(new MM.Coordinate(0, 10, 0)) | ||
.to(new MM.Coordinate(0, 0, 0)) | ||
.easing('linear') | ||
.t(0.5); | ||
.from(new MM.Coordinate(0, 10, 0)) | ||
.to(new MM.Coordinate(0, 0, 0)) | ||
.easing('linear') | ||
.t(0.5); | ||
@@ -62,2 +56,3 @@ expect(map.coordinate.column).toEqual(5); | ||
ease.run(10); | ||
expect(ease.running()).toBeTruthy(); | ||
}); | ||
@@ -69,2 +64,3 @@ waits(200); | ||
expect(map.coordinate.zoom).toEqual(0); | ||
expect(ease.running()).toBeFalsy(); | ||
}); | ||
@@ -80,2 +76,3 @@ }); | ||
ease.run(10, sink.receive); | ||
expect(ease.running()).toBeTruthy(); | ||
}); | ||
@@ -85,2 +82,3 @@ waits(200); | ||
expect(sink.receive).toHaveBeenCalledWith(map); | ||
expect(ease.running()).toBeFalsy(); | ||
}); | ||
@@ -93,5 +91,6 @@ }); | ||
ease.map(map).from(new MM.Coordinate(2, 2, 2)) | ||
.to(new MM.Coordinate(1, 1, 1)); | ||
.to(new MM.Coordinate(1, 1, 1)); | ||
runs(function() { | ||
ease.optimal(20); | ||
expect(ease.running()).toBeTruthy(); | ||
}); | ||
@@ -103,9 +102,27 @@ waits(200); | ||
expect(map.coordinate.zoom).toEqual(1); | ||
expect(ease.running()).toBeFalsy(); | ||
}); | ||
}); | ||
it('can be stopped', function() { | ||
var ease = easey(); | ||
spyOn(sink, 'receive'); | ||
runs(function() { | ||
ease.map(map).from(new MM.Coordinate(0, 10, 0)) | ||
.to(new MM.Coordinate(0, 0, 0)).run(10); | ||
expect(ease.running()).toBeTruthy(); | ||
ease.stop(sink.receive); | ||
}); | ||
waits(500); | ||
runs(function() { | ||
expect(sink.receive).toHaveBeenCalled(); | ||
expect(ease.running()).toBeFalsy(); | ||
}); | ||
}); | ||
it('resets from after a run', function() { | ||
var ease = easey(); | ||
ease.map(map).from(new MM.Coordinate(0, 10, 0)) | ||
.to(new MM.Coordinate(0, 0, 0)).run(1); | ||
.to(new MM.Coordinate(0, 0, 0)).run(1); | ||
waits(50); | ||
@@ -112,0 +129,0 @@ runs(function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
462752
24
10044
1