From 9eb2fc67d27f97b2d00be148323e6e2b3f51e087 Mon Sep 17 00:00:00 2001 From: David Ruisinger Date: Tue, 14 Jun 2016 15:46:48 +0200 Subject: [PATCH] fix(popover): allow target element to be positioned at left:0 --- src/components/popover/popover.ts | 9 ++++---- src/components/popover/test/basic/main.html | 25 +++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/popover/popover.ts b/src/components/popover/popover.ts index 944aff4e3fe..291ca7cf8a1 100644 --- a/src/components/popover/popover.ts +++ b/src/components/popover/popover.ts @@ -268,8 +268,9 @@ class PopoverTransition extends Transition { // If ev was passed, use that for target element let targetDim = ev && ev.target && ev.target.getBoundingClientRect(); - let targetTop = targetDim && targetDim.top || (bodyHeight / 2) - (popoverHeight / 2); - let targetLeft = targetDim && targetDim.left || bodyWidth / 2 - (popoverWidth / 2); + let targetTop = (targetDim && 'top' in targetDim) ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2); + let targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : (bodyWidth / 2) - (popoverWidth / 2); + let targetWidth = targetDim && targetDim.width || 0; let targetHeight = targetDim && targetDim.height || 0; @@ -328,8 +329,8 @@ class PopoverTransition extends Transition { // If ev was passed, use that for target element let targetDim = ev && ev.target && ev.target.getBoundingClientRect(); - let targetTop = targetDim && targetDim.top || (bodyHeight / 2) - (popoverHeight / 2); - let targetLeft = targetDim && targetDim.left || bodyWidth / 2; + let targetTop = (targetDim && 'top' in targetDim) ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2); + let targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : (bodyWidth / 2); let targetWidth = targetDim && targetDim.width || 0; let targetHeight = targetDim && targetDim.height || 0; diff --git a/src/components/popover/test/basic/main.html b/src/components/popover/test/basic/main.html index 3ebe3c85fc2..55361f58587 100644 --- a/src/components/popover/test/basic/main.html +++ b/src/components/popover/test/basic/main.html @@ -18,22 +18,29 @@ - + - - + + + + Present List Popover left + + + Present List Popover right + + + - +
+ -
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vel ipsum in purus mollis dictum eget vitae purus. Nulla ultrices est odio, a maximus velit pretium ac. Donec vel elementum mi. Proin elementum pulvinar neque, in lacinia nibh tempus auctor. Nam sapien velit, commodo ac nibh a, maximus ullamcorper nunc. Integer luctus tortor dignissim, dictum neque at, scelerisque purus. Vivamus nec erat vel magna posuere euismod. Sed ac augue eu tellus tincidunt fermentum eget sit amet nunc. Donec sit amet mi libero. Cras nunc arcu, ultrices nec sapien eu, convallis posuere libero. Pellentesque vulputate lacus eros, at lobortis lorem egestas et. Vestibulum tempus quam in efficitur lobortis. Maecenas consectetur consequat sem pharetra aliquet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.