Skip to content

Commit 90e29af

Browse files
committed
fix: ghost styles while dragging
1 parent f5c0432 commit 90e29af

File tree

8 files changed

+43
-22
lines changed

8 files changed

+43
-22
lines changed

src/demo/sass/demo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ body {
176176
display: inline-block;
177177
width: 224px;
178178
height: 150px;
179-
mask-image: url("assets/img/formeo-logo.svg");
179+
mask-image: url("/assets/img/formeo-logo.svg");
180180
mask-repeat: no-repeat;
181181
background-image: linear-gradient(
182182
-60deg,

src/lib/js/components/data.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export default class Data {
3838
const callbackPath = Array.isArray(path) ? path.join('.') : path
3939
const callBackGroups = Object.keys(this.setCallbacks).filter(setKey => new RegExp(setKey).test(callbackPath))
4040
const cbArgs = { newVal, oldVal, path }
41-
callBackGroups.forEach(cbGroup => this.setCallbacks[cbGroup].forEach(cb => cb(cbArgs)))
41+
for (const cbGroup of callBackGroups) {
42+
for (const cb of this.setCallbacks[cbGroup]) {
43+
cb(cbArgs)
44+
}
45+
}
4246

4347
if (!this.disableEvents) {
4448
const change = this.getChangeType(oldVal, newVal)

src/lib/js/components/rows/row.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ export default class Row extends Component {
7676
* @return {Object} edit window dom config for Row
7777
*/
7878
get editWindow() {
79-
const _this = this
80-
8179
const fieldsetInput = {
8280
tag: 'input',
83-
id: _this.id + '-fieldset',
81+
id: `${this.id}-fieldset`,
8482
attrs: {
8583
type: 'checkbox',
8684
checked: this.get('config.fieldset'),
@@ -118,11 +116,11 @@ export default class Row extends Component {
118116
attrs: {
119117
type: 'text',
120118
ariaLabel: 'Legend for fieldset',
121-
value: _this.get('config.legend'),
119+
value: this.get('config.legend'),
122120
placeholder: 'Legend',
123121
},
124122
action: {
125-
input: ({ target: { value } }) => _this.set('config.legend', value),
123+
input: ({ target: { value } }) => this.set('config.legend', value),
126124
},
127125
className: '',
128126
}
@@ -186,9 +184,9 @@ export default class Row extends Component {
186184
return
187185
}
188186

189-
const width = parseFloat((100 / columns.length).toFixed(1)) / 1
187+
const width = Number.parseFloat((100 / columns.length).toFixed(1)) / 1
190188

191-
columns.forEach(column => {
189+
for (const column of columns) {
192190
column.removeClasses(bsColRegExp)
193191
const colDom = column.dom
194192
const newColWidth = numToPercent(width)
@@ -201,7 +199,7 @@ export default class Row extends Component {
201199
column.refreshFieldPanels()
202200
}, ANIMATION_SPEED_FAST)
203201
document.dispatchEvent(events.columnResized)
204-
})
202+
}
205203

206204
this.updateColumnPreset()
207205
}
@@ -283,7 +281,6 @@ export default class Row extends Component {
283281
* @return {Object} columnPresetControlConfig
284282
*/
285283
get columnPresetControlConfig() {
286-
const _this = this
287284
const layoutPreset = {
288285
tag: 'select',
289286
attrs: {
@@ -293,14 +290,7 @@ export default class Row extends Component {
293290
action: {
294291
change: ({ target }) => {
295292
const { value } = target
296-
297-
// forEach(target.children, option => {
298-
// option.selected = option.value === value
299-
// })
300-
// if (value !== 'custom') {
301-
// removeCustomOption(this.dom)
302-
_this.setColumnWidths(value)
303-
// }
293+
this.setColumnWidths(value)
304294
},
305295
},
306296
options: this.getColumnPresetOptions,

src/lib/js/components/stages/stage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ export default class Stage extends Component {
8585
disabled: false,
8686
onAdd: this.onAdd.bind(this),
8787
onRemove: this.onRemove.bind(this),
88-
onStart: () => (Stages.active = this),
88+
onStart: () => {
89+
Stages.active = this
90+
},
8991
onSort: this.onSort.bind(this),
9092
draggable: `.${ROW_CLASSNAME}`,
9193
handle: '.item-move',

src/lib/sass/components/_column.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@
116116
display: none;
117117
}
118118
}
119+
120+
&.sortable-ghost {
121+
background-color: color.$column-highlight-color;
122+
box-shadow: 0 0 0 1px color.$column-outline-color;
123+
* {
124+
opacity: 0;
125+
}
126+
}
119127
}
120128

121129
// this is column styleing in the row edit window
@@ -164,6 +172,7 @@
164172

165173
.column-moving {
166174
background-color: color.$column-highlight-color;
175+
167176
.action-btn-wrap {
168177
button {
169178
background-color: color.$column-highlight-color;

src/lib/sass/components/_field.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@
6868
&.field-type-hidden {
6969
border: 1px dashed color.$gray-lighter;
7070
}
71+
72+
&.sortable-ghost {
73+
background-color: color.$field-highlight-color;
74+
box-shadow: 0 0 0 1px color.$field-outline-color;
75+
* {
76+
opacity: 0;
77+
}
78+
}
7179
}
7280

7381
.field-tag {

src/lib/sass/components/_row.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,18 @@
7474
display: none;
7575
}
7676
}
77+
78+
&.sortable-ghost {
79+
background-color: color.$row-highlight-color;
80+
box-shadow: 0 0 0 1px color.$row-outline-color;
81+
* {
82+
opacity: 0;
83+
}
84+
}
7785
}
7886

7987
.row-moving {
80-
background-color: color.$row-highlight-color;
88+
background-color: color.$row-highlight-color !important;
8189
.action-btn-wrap {
8290
button {
8391
background-color: color.$row-highlight-color;

vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const libConfig = {
7070
const demoConfig = {
7171
...sharedConfig,
7272
root: 'src/demo',
73-
base: '',
73+
base: '/',
7474
resolve: {
7575
alias: {
7676
'formeo': resolve(__dirname, 'src/lib/js/index.js'),

0 commit comments

Comments
 (0)