bounds: "#quiz",
onDragParams: [{}],
onDrag: function() {
+ $(this.target).addClass("isDragging").removeClass("isNext")
+
$this.offsetLeftItemDragged = $(this.target).offset().left
$this.offsetRightItemDragged = $(this.target).offset().left + $(this.target).outerWidth()
let direction = this.getDirection()
let zone = $this.getZoneOverlap($this.offsetLeftItemDragged,$this.offsetRightItemDragged)
+ // fix bug scale !important from css
+ gsap.to(this.target, {
+ scale: 1,
+ duration: 0,
+ immediateRender: true
+ })
+
//set rotation
$this.rotateItem(this,direction)
},
onDragEnd: function() {
//
- let zone = $this.getZoneOverlap($this.offsetLeftItemDragged,$this.offsetRightItemDragged),
- slot = $this.getSlotInformations(zone);
+ let zone = $this.getZoneOverlap($this.offsetLeftItemDragged,$this.offsetRightItemDragged)
+ let slot = false
+ if(zone) {
+ slot = $this.getSlotInformations(zone)
+ }
let target = $(this.target),
heightTarget = $(this.target).height()
//
- gsap.timeline().to(this.target, {
- width: slot.w,
- height: slot.h,
- x: slot.x,
- y: slot.y,
- fontSize: "14px",
- padding: "7px 8px",
- borderRadius: "8px",
- onStart: function() {
- target.addClass("onStart")
- },
- onComplete: function() {
- let html = target.html()
- $(zone).find(".slot:not(.active)").eq(0).addClass("active").html(html)
- target.remove()
- }
- })
- .to(".list .overlay", {
- y: -heightTarget,
- opacity: 0,
- onStart: function() {
- $($this.target).next().addClass("isNext")
- }
- }, "<")
- .to(".list .overlay", {
- y: 0,
- opacity: 1,
- duration: 0
- })
-
- //
- //$(".zone-2 .slot:not(.active)").eq(0).addClass("active")
+ if(slot) {
+ gsap.timeline().to(this.target, {
+ width: slot.w,
+ height: slot.h,
+ x: slot.x,
+ y: slot.y,
+ fontSize: "14px",
+ padding: "7px 8px",
+ borderRadius: "8px",
+ onStart: function () {
+ target.addClass("isValidated")
+ },
+ onComplete: function () {
+ let html = target.html()
+ $(zone).find(".slot:not(.active)").eq(0).addClass("active").html(html)
+ target.remove()
+ }
+ })
+ .to(".list .overlay", {
+ y: -heightTarget,
+ opacity: 0,
+ onStart: function () {
+ $(".list-item.isValidated").next().addClass("isNext")
+ }
+ }, "<")
+ .to(".list .overlay", {
+ y: 0,
+ opacity: 1,
+ duration: 0
+ }, "+=1")
+ }
},
onRelease: function() {
//
$this.leaveZone()
+ //
+ if(!$this.getZoneOverlap($this.offsetLeftItemDragged,$this.offsetRightItemDragged)) {
+ gsap.to(this.target, {
+ x: 0,
+ y: 0,
+ })
+ }
+
+ $(this.target).removeClass("isDragging")
+
// reset list rotation
gsap.to(this.target, {
rotation: 0
el = $(zone).find(".slot")
return {"x" : x, "y" : y, "w" : w, "h": h, "el": el}
- }
+ },
+
+
}
export default QuizDragAndDrop;
z-index: 4
border: 2px solid $texts-color
top: 0
- &:nth-child(2)
- opacity: .64 !important
- +opacity(.8,background-color,$neutral-color)
- transform: scale(.92) !important
- z-index: 3
- top: 30px
- &:nth-child(3)
- opacity: .4 !important
- +opacity(.8,background-color,$neutral-color)
- transform: scale(.83) !important
- z-index: 2
- top: 60px
- &:nth-child(4)
- opacity: .16 !important
- +opacity(.8,background-color,$neutral-color)
- transform: scale(0.75) !important
- z-index: 1
- top: 87px
- &:not(:nth-child(-n+4)) // on cache les items à partir du 5ème
- opacity: 0 !important
- visibility: hidden
- &.onStart
- font-size: 14px
- border: 1px solid rgba($texts-color,.24)
- transition: border .3s, font-size .3s
- &:not(:nth-child(1))
- clip-path: polygon(0 90%, 100% 90%, 100% 100%, 0 100%)
&.isNext
- clip-path: polygon(0 0, 100% 0%, 100% 100%, 0 100%)
+ transform: scale(1) !important
transition: all .3s
+ &:not(.isDragging)
+ &:nth-child(2)
+ opacity: .64 !important
+ +opacity(.8,background-color,$neutral-color)
+ transform: scale(.92) !important
+ z-index: 3
+ top: 30px
+ &:nth-child(3)
+ opacity: .4 !important
+ +opacity(.8,background-color,$neutral-color)
+ transform: scale(.83) !important
+ z-index: 2
+ top: 60px
+ &:nth-child(4)
+ opacity: .16 !important
+ +opacity(.8,background-color,$neutral-color)
+ transform: scale(0.75) !important
+ z-index: 1
+ top: 87px
+ &:not(:nth-child(-n+4)) // on cache les items à partir du 5ème
+ opacity: 0 !important
+ visibility: hidden
+ &.isValidated
+ font-size: 14px
+ border: 1px solid rgba($texts-color,.24)
+ transition: border .3s, font-size .3s
+ &:not(:nth-child(1))
+ clip-path: polygon(0 90%, 100% 90%, 100% 100%, 0 100%)
+ transition: all .3s
+ pointer-events: none
+ &.isNext
+ clip-path: polygon(0 0, 100% 0%, 100% 100%, 0 100%)
+ transition: all .3s
&[data-direction=right]
transform: rotate(25deg)