start_controls_section( 'eppro_effects', [ 'label' => EPPRO_Elementor_Helper::panel_label( __( 'Effects', 'admore-widgets-suite' ) ), 'tab' => \Elementor\Controls_Manager::TAB_ADVANCED, ] ); // Parallax Effect $element->add_control( 'eppro_parallax_heading', [ 'label' => __( 'Parallax Effect', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::HEADING, ] ); $element->add_control( 'eppro_parallax_enable', [ 'label' => __( 'Enable Parallax', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', ] ); $element->add_control( 'eppro_parallax_speed', [ 'label' => __( 'Speed', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => -10, 'max' => 10, 'step' => 0.1 ] ], 'default' => [ 'size' => 0.5 ], 'condition' => [ 'eppro_parallax_enable' => 'yes' ], ] ); $element->add_control( 'eppro_parallax_direction', [ 'label' => __( 'Direction', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'vertical', 'options' => [ 'vertical' => __( 'Vertical', 'admore-widgets-suite' ), 'horizontal' => __( 'Horizontal', 'admore-widgets-suite' ), ], 'condition' => [ 'eppro_parallax_enable' => 'yes' ], ] ); // Floating Effect $element->add_control( 'eppro_floating_heading', [ 'label' => __( 'Floating Effect', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $element->add_control( 'eppro_floating_enable', [ 'label' => __( 'Enable Floating', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', ] ); $element->add_control( 'eppro_floating_distance', [ 'label' => __( 'Distance (px)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 5, 'max' => 100 ] ], 'default' => [ 'size' => 20 ], 'condition' => [ 'eppro_floating_enable' => 'yes' ], ] ); $element->add_control( 'eppro_floating_duration', [ 'label' => __( 'Duration (ms)', 'admore-widgets-suite' ), 'type' => \Elementor\Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 500, 'max' => 10000, 'step' => 100 ] ], 'default' => [ 'size' => 3000 ], 'condition' => [ 'eppro_floating_enable' => 'yes' ], ] ); $element->end_controls_section(); } /** * Before render widget */ public static function before_render( $element ): void { $settings = $element->get_settings(); // Parallax if ( 'yes' === ( $settings['eppro_parallax_enable'] ?? '' ) ) { wp_enqueue_script( 'eppro-effects' ); $element->add_render_attribute( '_wrapper', 'data-eppro-parallax', 'true' ); $element->add_render_attribute( '_wrapper', 'data-parallax-speed', $settings['eppro_parallax_speed']['size'] ?? 0.5 ); $element->add_render_attribute( '_wrapper', 'data-parallax-direction', $settings['eppro_parallax_direction'] ?? 'vertical' ); } // Floating if ( 'yes' === ( $settings['eppro_floating_enable'] ?? '' ) ) { wp_enqueue_script( 'eppro-effects' ); $element->add_render_attribute( '_wrapper', 'data-eppro-floating', 'true' ); $element->add_render_attribute( '_wrapper', 'data-floating-distance', $settings['eppro_floating_distance']['size'] ?? 20 ); $element->add_render_attribute( '_wrapper', 'data-floating-duration', $settings['eppro_floating_duration']['size'] ?? 3000 ); } } }