[Pkg-javascript-commits] [leaflet] 55/301: Adds Popup autoPanPadding(TopLeft & BottomRight) options. Fixes #1588
Jonas Smedegaard
js at moszumanska.debian.org
Mon Jan 27 22:22:41 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet.
commit 157500818e91f0005049cf6ea06d6246afae4486
Author: Alexander Burtsev <albburtsev at gmail.com>
Date: Wed Aug 14 17:57:48 2013 +0400
Adds Popup autoPanPadding(TopLeft & BottomRight) options. Fixes #1588
---
src/layer/Popup.js | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/layer/Popup.js b/src/layer/Popup.js
index def998b..6f07742 100644
--- a/src/layer/Popup.js
+++ b/src/layer/Popup.js
@@ -17,6 +17,8 @@ L.Popup = L.Class.extend({
closeButton: true,
offset: [0, 7],
autoPanPadding: [5, 5],
+ autoPanPaddingTopLeft: null,
+ autoPanPaddingBottomRight: null,
keepInView: false,
className: '',
zoomAnimation: true
@@ -257,21 +259,23 @@ L.Popup = L.Class.extend({
var containerPos = map.layerPointToContainerPoint(layerPos),
padding = L.point(this.options.autoPanPadding),
+ paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),
+ paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),
size = map.getSize(),
dx = 0,
dy = 0;
- if (containerPos.x + containerWidth > size.x) { // right
- dx = containerPos.x + containerWidth - size.x + padding.x;
+ if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right
+ dx = containerPos.x + containerWidth - size.x + paddingBR.x;
}
- if (containerPos.x - dx < 0) { // left
- dx = containerPos.x - padding.x;
+ if (containerPos.x - dx - paddingTL.x < 0) { // left
+ dx = containerPos.x - paddingTL.x;
}
- if (containerPos.y + containerHeight > size.y) { // bottom
- dy = containerPos.y + containerHeight - size.y + padding.y;
+ if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom
+ dy = containerPos.y + containerHeight - size.y + paddingBR.y;
}
- if (containerPos.y - dy < 0) { // top
- dy = containerPos.y - padding.y;
+ if (containerPos.y - dy - paddingTL.y < 0) { // top
+ dy = containerPos.y - paddingTL.y;
}
if (dx || dy) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet.git
More information about the Pkg-javascript-commits
mailing list