<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

wp_register_script( 'ecafe-tilt-js-3rd', ECAFE_ASSETS_PATH . 'js/baharni/tilt.jquery.js', array( 'jquery' ), ECAFE_VERSION, false );
wp_register_script( 'ecafe-tilt-js', ECAFE_ASSETS_PATH . 'js/custom/ecafe-tilt-custom.min.js', array( 'ecafe-tilt-js-3rd' ), ECAFE_VERSION, false );
wp_enqueue_script( 'ecafe-tilt-js' );
$tiltclass            = 'ec-tilt';
$tiltrotation         = ! empty( $settings['tiltrotation']['size'] ) ? $settings['tiltrotation']['size'] : 35;
$transformperspective = ! empty( $settings['transformperspective']['size'] ) ? $settings['transformperspective']['size'] : 1000;
$tiltscale            = ! empty( $settings['tiltscale']['size'] ) ? $settings['tiltscale']['size'] : 1;
$tiltspeed            = ! empty( $settings['tiltspeed']['size'] ) ? $settings['tiltspeed']['size'] : 300;
$tiltaxis             = ! empty( $settings['tiltaxis'] ) ? $settings['tiltaxis'] : 'null';
$tilteasing           = ! empty( $settings['tilteasing'] ) ? $settings['tilteasing'] : 'cubic-bezier(.03,.98,.52,.99)';

$this->add_render_attribute( 'ec_tilt', 'data-tilt', '', true );

	$this->add_render_attribute( 'ec_tilt', 'data-tilt-max', $tiltrotation, true );
	$this->add_render_attribute( 'ec_tilt', 'data-tilt-perspective', $transformperspective, true );
	$this->add_render_attribute( 'ec_tilt', 'data-tilt-scale', $tiltscale, true );
	$this->add_render_attribute( 'ec_tilt', 'data-tilt-speed', $tiltspeed, true );
	$this->add_render_attribute( 'ec_tilt', 'data-easing', $tilteasing, true );
if ( ! empty( $settings['tiltaxis'] ) && $settings['tiltaxis'] == 'x' ) {
	$this->add_render_attribute( 'ec_tilt', 'data-tilt-axis', 'x', true );
} elseif ( ! empty( $settings['tiltaxis'] ) && $settings['tiltaxis'] == 'y' ) {
	$this->add_render_attribute( 'ec_tilt', 'data-tilt-axis', 'y', true );
}
$tiltrender = $this->get_render_attribute_string( 'ec_tilt' );
