I want to create an oscillation effect of an object. I use the following code:
hypeDocument.customOscillationMotion = function(element, amplitude, frequency, phase) {
// Get the current time in milliseconds
var currentTime = new Date().getTime();
// Calculate the vertical displacement based on the amplitude, frequency, and phase
var displacement = amplitude * Math.sin((2 * Math.PI * frequency * currentTime / 1000) + phase);
// Apply the displacement to the element's position
var newY = element.originalTop() + displacement;
element.setTop(newY);
};
// Set the parameters for the oscillation motion
var elementId = 'yourCycleElementId';
var amplitude = 10;
var frequency = 1;
var phase = 0;
// Get the element by its ID
var cycleElement = hypeDocument.getElementById(elementId);
// Start the oscillation motion
hypeDocument.customOscillationMotion(cycleElement, amplitude, frequency, phase);
However I cannot make this work. Any help?
Thank you in advance.