识别销毁&的参考重新初始化Elementor中的刷卡器 [英] Identify Reference to Destroy & Re-Initialize Swiper in Elementor

查看:102
本文介绍了识别销毁&的参考重新初始化Elementor中的刷卡器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Elementor Pro(WordPress页面构建器)与 Swiper 完美集成,将其GUI与JS参数和数据库内容.

Elementor Pro (the WordPress page builder) integrates beautifully with Swiper, tying their GUI to the JS parameters and database content.

但是,对于我的项目,我需要对Swiper进行一些更改"CoverFlow"皮肤初始参数(显示更多幻灯片,更改3D效果朝向的方向...).

However, for my project, I need to make some changes to the Swiper "CoverFlow" skin Init parameters (show more slides, change the 3D effect facing direction...).

我希望使用Swiper API的销毁方法:

My hope is to to use the Destroy method of the Swiper API which looks like:

mySwiper.destroy(deleteInstance, cleanStyles);

然后,我可以使用自己的自定义参数再次初始化Swiper.挑战在于Elementor在frontend.js 是一个复杂的匿名函数,它实际上并不允许我知道"mySwiper"是什么...在第567行:

Then I can initialize the Swiper again, with my own custom parameters. The challenge is that the way Elementor calls Swiper in frontend.js is a complex anonymous function that doesn't really allow me to know what "mySwiper" would be... On line 567:

this.swipers.main = new Swiper(this.elements.$mainSwiper, this.getSwiperOptions());

如果有人可以帮助我理解Init之后"this.swipers.main"的含义,我将非常感激,这样我就可以销毁该swiper并使用自己的参数再次对其进行初始化.

I would be so grateful if someone could please help me understand what "this.swipers.main" would translate to after Init so that I can destroy the swiper and initialize it again with my own parameters.

很显然,我无法编辑frontend.js本身,因为它是需要更新的插件文件.

为谁教我如何捕鱼以及为其他类似情况解决这些类型的难题的方法所用的加分.

Extra points for whomever teaches me how to fish and what the methodology is to solve these types of puzzles for other similar situations.

推荐答案

您可以为Elementor小部件提供一个ID,例如: slider1 ,然后使用JS,您可以使用:

You can give an ID to the Elementor widget ex: slider1 and then with JS you can use:

var sliderInstance = document.querySelector('#slider1 .swiper-container').swiper;

此后,您可以在任意位置调用 sliderInstance.destroy().

After this you can call sliderInstance.destroy() wherever you want.

如果要再次初始化它,可以调用:

And if you want to initialize it again you can call:

var sliderInstance = new Swiper('#slider1 .swiper-container', {
    //options
});

这篇关于识别销毁&的参考重新初始化Elementor中的刷卡器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆