Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from cryogenian/off-set
Browse files Browse the repository at this point in the history
getCenterOffset signature is fixed, off function is added
  • Loading branch information
cryogenian authored Feb 13, 2018
2 parents 59fb204 + 9538f33 commit 0c76236
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Leaflet/Core/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exports.eventCenter_ = function(Nothing, Just, Tuple, e) {
if (e.center === undefined) {
return Nothing;
} else {
return Just(Tuple(e.center.x)(e.center.y));
return Just(e.center);
}
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/Leaflet/Core/Event.purs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ foreign import eventZoom_
e a. Fn3 (Maybe a) (a Maybe a) Event (Eff (dom DOM|e) (Maybe Zoom))

foreign import eventCenter_
e a. Fn4 (Maybe a) (a Maybe a) (a a a × a) Event (Eff (dom DOM|e) (Maybe Point))
e a. Fn4 (Maybe a) (a Maybe a) (a a a × a) Event (Eff (dom DOM|e) (Maybe LatLng))

foreign import eventContainerPoint_
e a. Fn4 (Maybe a) (a Maybe a) (a a a × a) Event (Eff (dom DOM|e) (Maybe Point))
Expand All @@ -36,7 +36,7 @@ eventCenter
m e
. MonadEff (domDOM|e) m
Event
m (Maybe Point)
m (Maybe LatLng)
eventCenter e =
liftEff $ runFn4 eventCenter_ Nothing Just Tuple e

Expand Down
5 changes: 5 additions & 0 deletions src/Leaflet/Core/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ exports.once_ = function(e, cb, l) {
};
};

exports.off_ = function(e, l) {
return function() {
l.off(e);
};
};

exports.addLayer_ = function(layer, leaflet) {
return function() {
Expand Down
13 changes: 13 additions & 0 deletions src/Leaflet/Core/Layer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Leaflet.Core.Layer
, addLayer
, removeLayer
, layerGroup
, off
) where

import Prelude
Expand Down Expand Up @@ -91,6 +92,9 @@ foreign import rectangle_
foreign import on_
e. Fn3 String (T.Event Eff (dom DOM|e) Unit) T.Evented (Eff (dom DOM|e) Unit)

foreign import off_
e. Fn2 String T.Evented (Eff (dom DOM|e) Unit)

foreign import once_
e. Fn3 String (T.Event Eff (dom DOM|e) Unit) T.Evented (Eff (dom DOM|e) Unit)

Expand Down Expand Up @@ -269,6 +273,15 @@ once
once e fn l =
liftEff $ runFn3 once_ e fn l

off
e m
. MonadEff (domDOM|e) m
String
T.Evented
m Unit
off e l =
liftEff $ runFn2 off_ e l

setIcon
m e
. MonadEff (domDOM|e) m
Expand Down
8 changes: 4 additions & 4 deletions src/Leaflet/Core/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ exports.getMapPanePos_ = function(Tuple, leaflet) {
};
};

exports.getCenterOffset_ = function(Tuple, point, leaflet) {
return function() {
var res = leaflet._getCenterOffset({x: point[0], y: point[1]});
return Tuple (res.x) (res.y);
exports.getCenterOffset_ = function(mkPoint, latLng, leaflet) {
return function() {
var res = leaflet._getCenterOffset(latLng);
return mkPoint (res.x) (res.y);
};
};

Expand Down
8 changes: 4 additions & 4 deletions src/Leaflet/Core/Map.purs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ foreign import getMapPanePos_
e. Fn2 (Int Int T.Point) T.Leaflet (Eff (dom DOM|e) T.Point)

foreign import getCenterOffset_
e. Fn3 (Int Int T.Point) (Array Int) T.Leaflet (Eff (dom DOM|e) T.Point)
e. Fn3 (Int Int T.Point) T.LatLng T.Leaflet (Eff (dom DOM|e) T.Point)

foreign import getMaxZoom_
e. T.Leaflet Eff (dom DOM|e) T.Zoom
Expand Down Expand Up @@ -162,11 +162,11 @@ getMapPanePos l =
getCenterOffset
e m
. MonadEff (domDOM|e) m
T.Point
T.LatLng
T.Leaflet
m T.Point
getCenterOffset (a × b) l =
liftEff $ runFn3 getCenterOffset_ Tuple [a, b] l
getCenterOffset a b =
liftEff $ runFn3 getCenterOffset_ Tuple a b

getMaxZoom
e m
Expand Down
3 changes: 1 addition & 2 deletions src/Leaflet/Plugin/Heatmap.purs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ onAdd opts items lay leaf = do
offset ← LC.getCenterOffset center leaf
panePos ← LC.getMapPanePos leaf
let coord = offset `LC.scalePoint` (-scale) # flip LC.subtractPoint panePos
LC.setTransform canvasEl offset scale
LC.setTransform canvasEl coord scale

when (threeD && isZoom) $ LC.mapToEvented leaf # LC.on "zoomanim" zoomAnim

LC.mapToEvented leaf # LC.on "moveend" reset

redraw canvas items opts leaf
Expand Down

0 comments on commit 0c76236

Please sign in to comment.