Forum Discussion
GSAP 3.5.1 ( latest version ) is now included in Storyline 360
I used the gsap hitTest but it's not working. I'm sure I'm doing something wrong. I first set the targetElement and hammerElement positions when the timeline begins:
var targetElement = document.querySelectorAll("[data-acc-text='targetBox']")
var hammerElement = document.querySelectorAll("[data-acc-text='hammer01']")
gsap.set(targetElement, {x:500, y:200});
gsap.set(hammerElement, {x:500, y:800});
and then I call this when user hits up key:
var hammerElement = document.querySelectorAll("[data-acc-text='hammer01']")
var targetElement = document.querySelectorAll("[data-acc-text='targetBox']")
gsap.to(hammerElement, .25,{y:"-=200", onUpdate:checkHit});
function checkHit() {
if (Draggable.hitTest(hammerElement, targetElement)){
gsap.set(targetElement, {x:500, y:100});
}
}
The hammerElement moves as it should but the function isn't working.