Basic collision detection
parent
1744172468
commit
266b593938
|
@ -18,7 +18,7 @@
|
||||||
<CascadeSelectSub :options="options" :selectionPath="selectionPath" class="p-cascadeselect-items"
|
<CascadeSelectSub :options="options" :selectionPath="selectionPath" class="p-cascadeselect-items"
|
||||||
:optionLabel="optionLabel" :optionValue="optionValue" :level="0" :templates="$slots"
|
:optionLabel="optionLabel" :optionValue="optionValue" :level="0" :templates="$slots"
|
||||||
:optionGroupLabel="optionGroupLabel" :optionGroupChildren="optionGroupChildren"
|
:optionGroupLabel="optionGroupLabel" :optionGroupChildren="optionGroupChildren"
|
||||||
@option-select="onOptionSelect" @optiongroup-select="onOptionGroupSelect" :dirty="dirty" />
|
@option-select="onOptionSelect" @optiongroup-select="onOptionGroupSelect" :dirty="dirty" :root="true" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ObjectUtils from '../utils/ObjectUtils';
|
import ObjectUtils from '../utils/ObjectUtils';
|
||||||
|
import DomHandler from '../utils/DomHandler';
|
||||||
import Ripple from '../ripple/Ripple';
|
import Ripple from '../ripple/Ripple';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -34,7 +35,8 @@ export default {
|
||||||
optionGroupChildren: Array,
|
optionGroupChildren: Array,
|
||||||
parentActive: Boolean,
|
parentActive: Boolean,
|
||||||
dirty: Boolean,
|
dirty: Boolean,
|
||||||
templates: null
|
templates: null,
|
||||||
|
root: Boolean
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -50,6 +52,10 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.root) {
|
||||||
|
this.position();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
parentActive(newValue) {
|
parentActive(newValue) {
|
||||||
|
@ -156,6 +162,17 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
},
|
||||||
|
position() {
|
||||||
|
const parentItem = this.$el.parentElement;
|
||||||
|
const containerOffset = DomHandler.getOffset(parentItem);
|
||||||
|
const viewport = DomHandler.getViewport();
|
||||||
|
const sublistWidth = this.$el.offsetParent ? this.$el.offsetWidth : DomHandler.getHiddenElementOuterWidth(this.$el);
|
||||||
|
const itemOuterWidth = DomHandler.getOuterWidth(parentItem.children[0]);
|
||||||
|
|
||||||
|
if ((parseInt(containerOffset.left, 10) + itemOuterWidth + sublistWidth) > (viewport.width - DomHandler.calculateScrollbarWidth())) {
|
||||||
|
this.$el.style.left = '-100%';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
directives: {
|
directives: {
|
||||||
|
|
Loading…
Reference in New Issue