Skip to content

Commit

Permalink
refactor: move remove element to Util.js
Browse files Browse the repository at this point in the history
  • Loading branch information
themustafaomar committed Jun 25, 2021
1 parent f8539c3 commit f4a7db7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/Map/createMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function createMarkers(markers = {}, isRecentlyCreated = false) {
point = this.getMarkerPosition(markerConfig)
uid = markerConfig.coords.join(':')

// We're checking if recently created marker is already exists
// We're checking if recently created marker is already existed
// If exists we don't need to create it again, so we'll continute
// Becuase we may have more than one marker.
if (isRecentlyCreated) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/Map/createTooltip.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Util from '../Util/Util'

export default function createTooltip() {
const map = this, tooltip = Util.createElement('div', 'jvm-tooltip')
const tooltip = Util.createElement('div', 'jvm-tooltip')

this.tooltip = Util.$(document.body.appendChild(tooltip))

this.container.on('mousemove', event => {
if (map.tooltip.selector.style.display === 'block') {
if (this.tooltip.selector.style.display === 'block') {
const container = this.container.selector.querySelector('#jvm-regions-group').getBoundingClientRect()
const space = 5 // Space between the cursor and tooltip element

Expand Down
4 changes: 4 additions & 0 deletions src/js/Util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const Util = {
return el
},

removeElement(target) {
target.parentNode.removeChild(target)
},

$: selector => new DomHandler(selector),

hyphenate: string => string.replace(/[\w]([A-Z])/g, m => `${m[0]}-${m[1]}`).toLowerCase(),
Expand Down

0 comments on commit f4a7db7

Please sign in to comment.