Skip to content

Commit

Permalink
refactor: remove finished timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Mar 2, 2020
1 parent 9c2d83d commit 08a6d0c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/demo/js/options/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ const config = {
events: {
onRender: element => {
console.log(element)
setTimeout(() => {
const onRenderTimeout = setTimeout(() => {
// formeo.Components.fields.get(element.id).toggleEdit(true)
element.querySelector('.next-group').click()
clearTimeout(onRenderTimeout)
}, 333)
},
},
Expand Down
4 changes: 0 additions & 4 deletions src/js/common/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,6 @@ class DOM {
document.dispatchEvent(events.columnResized)
})

// fields.forEach(fieldId => Fields.get(fieldId).panelNav.refresh())

// setTimeout(() => fields.forEach(fieldId => Fields.get(fieldId).panelNav.refresh()), 250)

dom.updateColumnPreset(row)
}

Expand Down
38 changes: 18 additions & 20 deletions src/js/components/fields/edit-panel-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,27 @@ export default class EditPanelItem {
}
const hideFields = fields => {
fields = Array.isArray(fields) ? fields : [fields]
setTimeout(
() =>
fields.forEach(field => {
if (field.dom) {
field = field.dom
}
field.style.display = 'none'
}),
ANIMATION_SPEED_BASE
)
const hideFieldsTimeout = setTimeout(() => {
fields.forEach(field => {
if (field.dom) {
field = field.dom
}
field.style.display = 'none'
})
clearTimeout(hideFieldsTimeout)
}, ANIMATION_SPEED_BASE)
}
const showFields = fields => {
fields = Array.isArray(fields) ? fields : [fields]
setTimeout(
() =>
fields.forEach(field => {
if (field.dom) {
field = field.dom
}
field.removeAttribute('style')
}),
ANIMATION_SPEED_BASE
)
const showFieldsTimeout = setTimeout(() => {
fields.forEach(field => {
if (field.dom) {
field = field.dom
}
field.removeAttribute('style')
})
clearTimeout(showFieldsTimeout)
}, ANIMATION_SPEED_BASE)
}
const actions = new Map([
[
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/fields/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,15 @@ export default class Field extends Component {
* Updates the conditions panel when linked field data changes
*/
updateConditionsPanel = () => {
setTimeout(() => {
const updateConditionsTimeout = setTimeout(() => {
const newConditionsPanel = this.editPanels.find(({ name }) => name === 'conditions')
if (!newConditionsPanel) {
return null
}
const newProps = newConditionsPanel.createProps()
const currentConditionsProps = this.dom.querySelector('.field-edit-conditions')
currentConditionsProps.parentElement.replaceChild(newProps, currentConditionsProps)
clearTimeout(updateConditionsTimeout)
}, ANIMATION_SPEED_BASE)
}

Expand Down

0 comments on commit 08a6d0c

Please sign in to comment.