2017 © Pedro Peláez
 

yii2-extension yii2-swiper-widget

Yii2 Swiper Widget

image

kriss/yii2-swiper-widget

Yii2 Swiper Widget

  • Friday, October 20, 2017
  • by kriss
  • Repository
  • 1 Watchers
  • 3 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 43 % Grown

The README.md

Yii2 Swiper Widget

Yii2 Swiper Widget, (*1)

  • 配置方便, (*2)

  • 同一个界面可以存在多个轮播,且不冲突, (*3)

  • swiper 4.0 +, (*4)

安装

composer require kriss/yii2-swiper-widget
"kriss/yii2-swiper-widget": "^1.0"

简单使用

显示轮播, (*5)

<?php
use yii\helpers\Html;

echo \kriss\swiper\SwiperWidget::widget([
    'slides' => [
        Html::img('http://img.zcool.cn/community/01665258173c34a84a0d304fc68fdf.jpg'),
        Html::img('http://img.zcool.cn/community/01665258173c34a84a0d304fc68fdf.jpg'),
        Html::img('http://img.zcool.cn/community/01665258173c34a84a0d304fc68fdf.jpg'),
    ],
    'pagination' => true,
    'navigation' => true,
    'scrollbar' => true,
    'clientOptions' => [
        'speed' => 200,
        'loop' => true,
        'on' => [
            'init' => new \yii\web\JsExpression('function() {}')
        ],
    ]
]);

高级使用

自定义操控,自定义js, (*6)

<?php
use yii\helpers\Html;

// swiper js 初始化后赋值给的变量名
$swiperEl = 'swiper';
echo \kriss\swiper\SwiperWidget::widget([
    'slides' => [
        Html::img('http://img.zcool.cn/community/01665258173c34a84a0d304fc68fdf.jpg'),
        Html::img('http://img.zcool.cn/community/01665258173c34a84a0d304fc68fdf.jpg'),
        Html::img('http://img.zcool.cn/community/01665258173c34a84a0d304fc68fdf.jpg'),
    ],
    'pagination' => true,
    'navigation' => true,
    'scrollbar' => true,
    'swiperEl' => $swiperEl, // 在此处传入
    'clientOptions' => [
        'speed' => 200,
        'loop' => true,
    ]
]);
// 下一个触发按钮
echo Html::button('next', ['id' => 'to-next']);

$js = <<<JS
 // 点击之后触发下一个,更多js操作参考官方
 $('#to-next').click(function() {
   {$swiperEl}.slideNext();
 });
JS;
$this->registerJs($js);

单页面宣传海报,带动画

使用 AnimatedSwiperSlideWidget, (*7)

echo SwiperWidget::widget([
    'slides' => [
        AnimatedSwiperSlideWidget::widget([
            'imageBaseUrl' => '@public/images/post',
            'bgUrl' => 'bg.jpg',
            'itemSizeUnit' => 'rem',
            'items' => [
                ['bonus_01.png', [6.4, .87, 0, .3], ['zoomIn', 1.5, 0]],
                ['bonus_02.jpg', [6.4, .55, 1.5, 0], ['fadeIn', 0.5, 1.5]],
                ['001.png', [6.4, 3.75, 2.8, 0], ['rotateInDownLeft', 0.5, 2]],
                ['002.png', [6.4, 3.75, 2.8, 0], ['bounceInDown', 1.5, 2.5]],
                ['003.png', [6.4, 2.25, 6.4, 0], ['fadeInUp', 0.5, 4]],
            ],
        ]),
        AnimatedSwiperSlideWidget::widget([
            'imageBaseUrl' => '@public/images/post',
            'bgUrl' => 'bg.jpg',
            'itemSizeUnit' => 'rem',
            'items' => [
                ['bonus_01.png', [6.4, .87, 0, .3], ['zoomIn', 1.5, 0]],
                ['bonus_02.jpg', [6.4, .55, 1.5, 0], ['fadeIn', 0.5, 1.5]],
                ['001.png', [6.4, 3.75, 2.8, 0], ['rotateInDownLeft', 0.5, 2]],
                ['002.png', [6.4, 3.75, 2.8, 0], ['bounceInDown', 1.5, 2.5]],
                ['003.png', [6.4, 2.25, 6.4, 0], ['fadeInUp', 0.5, 4]],
            ],
        ]),
    ],
    'pagination' => false,
    'navigation' => false,
    'clientOptions' => [
        'direction' => 'vertical',
        'on' => [
            'init' => new JsExpression('function() {swiperAnimateCache(this);swiperAnimate(this);}'),
            'slideChangeTransitionEnd' => new JsExpression('function() {swiperAnimate(this);}'),
        ],
    ],
]);

The Versions

20/10 2017

dev-master

9999999-dev

Yii2 Swiper Widget

  Sources   Download

MIT

The Requires

 

by Avatar kriss

extension yii2 widget swiper swiperjs

20/10 2017

v1.1

1.1.0.0

Yii2 Swiper Widget

  Sources   Download

MIT

The Requires

 

by Avatar kriss

extension yii2 widget swiper swiperjs

20/10 2017

v1.0

1.0.0.0

Yii2 Swiper Widget

  Sources   Download

MIT

The Requires

 

by Avatar kriss

extension yii2 widget swiper swiperjs