Skip to content

Commit

Permalink
rename some functions to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann committed Aug 20, 2020
1 parent 31608b7 commit cc69e7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/hoverClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import store from './store'
import filter from './filter'
import throttle from './throttle'
import { addEventListener as on, removeEventListener as off } from './eventListener'
import { addEventListener, removeEventListener } from './eventListener'
/**
* enable or disable hoverClass on mouseenter/leave if container Items
* @param {sortable} sortableContainer a valid sortableContainer
Expand All @@ -14,7 +14,7 @@ export default (sortableContainer: sortable, enable: boolean) => {
const hoverClasses = store(sortableContainer).getConfig('hoverClass').split(' ')
// add class on hover
if (enable === true) {
on(sortableContainer, 'mousemove', throttle((event) => {
addEventListener(sortableContainer, 'mousemove', throttle((event) => {
// check of no mouse button was pressed when mousemove started == no drag
if (event.buttons === 0) {
filter(sortableContainer.children, store(sortableContainer).getConfig('items')).forEach(item => {
Expand All @@ -27,15 +27,15 @@ export default (sortableContainer: sortable, enable: boolean) => {
}
}, store(sortableContainer).getConfig('throttleTime')))
// remove class on leave
on(sortableContainer, 'mouseleave', () => {
addEventListener(sortableContainer, 'mouseleave', () => {
filter(sortableContainer.children, store(sortableContainer).getConfig('items')).forEach(item => {
item.classList.remove(...hoverClasses)
})
})
// remove events
} else {
off(sortableContainer, 'mousemove')
off(sortableContainer, 'mouseleave')
removeEventListener(sortableContainer, 'mousemove')
removeEventListener(sortableContainer, 'mouseleave')
}
}
}
4 changes: 2 additions & 2 deletions src/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-env browser */
import { addData as data } from './data' // yuk, data really needs to be refactored
import { addData } from './data' // yuk, data really needs to be refactored
import filter from './filter'
import getIndex from './getIndex'
/**
Expand All @@ -18,7 +18,7 @@ export default (sortableContainer: HTMLElement, customItemSerializer: Function =
throw new Error('You need to provide a valid serializer for items and the container.')
}
// get options
const options = data(sortableContainer, 'opts')
const options = addData(sortableContainer, 'opts')

const item: string|undefined = options.items

Expand Down

0 comments on commit cc69e7f

Please sign in to comment.