-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eaedcfa
commit 9d7679c
Showing
14 changed files
with
209 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.sharee__hover { | ||
transform: translate(-50%, 0); | ||
} | ||
|
||
.sharee__dropdown.fade-down.sharee__hover.show { | ||
transform: translate(-50%, 0); | ||
} | ||
|
||
.sharee__dropdown.fade-down:not(.show) { | ||
transform: translate(-50%, -10px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Sharee from "../Sharee"; | ||
import Driver from "../drivers/Driver"; | ||
import DropdownStrategy from "./DropdownStrategy"; | ||
|
||
export default class HoverStrategy extends DropdownStrategy{ | ||
constructor(sharee: Sharee) { | ||
super(sharee); | ||
this.options.type = 'row' | ||
} | ||
|
||
destroy() { | ||
super.destroy(); | ||
} | ||
|
||
public render() { | ||
super.render(); | ||
this.shareeEl.classList.add('sharee__text') | ||
this.shareeEl.classList.add('sharee__hover') | ||
} | ||
|
||
protected show() { | ||
this.shareeEl.classList.add('showing') | ||
setTimeout(() => { | ||
this.shareeEl.classList.add('show') | ||
const bCR = this.sharee.targetElement.getBoundingClientRect(); | ||
const x = bCR.x; | ||
const y = bCR.y; | ||
if (this.sharee.lang.Direction === 'ltr') { | ||
this.shareeEl.style.left = `${x + (bCR.width / 2)}px`; | ||
this.shareeEl.style.right = 'unset'; | ||
} else { | ||
this.shareeEl.style.right = `${x}px`; | ||
this.shareeEl.style.left = 'unset'; | ||
} | ||
this.shareeEl.style.top = `${y + bCR.height}px`; | ||
}) | ||
} | ||
|
||
protected listenEvents() { | ||
this.shareeEl.addEventListener('mouseenter', this.shareElOnMouseEnter.bind(this)) | ||
this.shareeEl.addEventListener('mouseleave', this.shareElOnMouseLeave.bind(this)) | ||
const onMouseEnter = this.elementOnMouseEnter.bind(this) | ||
const onMouseLeave = this.elementOnMouseLeave.bind(this) | ||
this.sharee.targetElement.addEventListener('mouseenter', onMouseEnter) | ||
this.sharee.targetElement.addEventListener('mouseleave', onMouseLeave) | ||
this.eventListeners.push([this.sharee.targetElement, 'mouseenter', onMouseEnter]) | ||
this.eventListeners.push([this.sharee.targetElement, 'mouseleave', onMouseLeave]) | ||
} | ||
|
||
public renderDriver(driver: Driver) { | ||
driver.mainEl = document.createElement('a'); | ||
driver.mainEl.title = driver.getButtonText() | ||
if ('getLink' in driver) { | ||
// @ts-ignore | ||
driver.mainEl.href = driver.getLink(); | ||
} | ||
this.initDriverStyles(driver) | ||
this.listenDriverEvents(driver); | ||
const icon = document.createElement('div'); | ||
icon.innerHTML = driver.icon; | ||
driver.mainEl.appendChild(icon); | ||
|
||
return driver.mainEl; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters