Dismiss Notice
ВАШИ ПРАВА ОГРАНИЧЕНЫ!

Зарегистрируйтесь на форуме, чтобы стать полноценным участником сообщества!

Вопрос? Скриншоты

Discussion in 'Вопросы- ответы' started by iroder, May 19, 2019.

19.05.19 в 00:40
19.05.19 в 14:44
8
539
0
  1. TopicStarter Overlay
    iroder

    iroder Бывалый

    Joined:
    Jun 7, 2015
    Messages:
    265
    Best Answers:
    0
    Ratings:
    +35 / 12 / -0
    Всем привет. Хочу реализовать на сайте одну фичу, как на сайте 24video которая меняет скриншоты виде анимации при наведении на нее. Если кто-то делал у себя подскажите.

    ec364d9b-8090-4990-8445-c46ebdba713b

    движок dle
     
  2. salomonkayn

    Забанен

    Joined:
    Sep 23, 2018
    Messages:
    388
    Best Answers:
    1
    Ratings:
    +118 / 24 / -0
    Code:
    <img class="js-hover" src='https://img.24video.site/2638/2638147/thumb320_1.jpg' data='https://img.24video.site/2638/2638147/thumb320_2.jpg,https://img.24video.site/2638/2638147/thumb320_3.jpg,https://img.24video.site/2638/2638147/thumb320_3.jpg'>
    
    Code:
    $(function() {
        $('.js-hover').hover(function() {
            var _this = this,
                images = _this.getAttribute('data').split(','),
                counter = 0;
    
            this.setAttribute('data-src', this.src);
            _this.timer = setInterval(function(){
                if(counter > images.length) {
                    counter = 0;
                }
                if (images[counter] != undefined) {
                    _this.src = images[counter];
                } else {
                    _this.src = _this.getAttribute('data-src');
                }
    
                counter++;
            }, 750);
    
        }, function() {
            this.src = this.getAttribute('data-src');
            clearInterval(this.timer);
        });
    });
    
     
    • Нравится Нравится x 1
  3. Tolstyak87

    Tolstyak87 Бывалый

    Joined:
    Mar 21, 2018
    Messages:
    638
    Best Answers:
    2
    Ratings:
    +81 / 19 / -0
    salomonkayn я так понимаю, первая часть в шаблон, а вторая в энджин?
     
  4. TopicStarter Overlay
    iroder

    iroder Бывалый

    Joined:
    Jun 7, 2015
    Messages:
    265
    Best Answers:
    0
    Ratings:
    +35 / 12 / -0
    движок dle
     
  5. TopicStarter Overlay
    iroder

    iroder Бывалый

    Joined:
    Jun 7, 2015
    Messages:
    265
    Best Answers:
    0
    Ratings:
    +35 / 12 / -0
    salomonkayn Объясни пожалуйста по подробнее. )
     
  6. upload

    PRO Users

    Joined:
    Nov 9, 2016
    Messages:
    208
    Best Answers:
    3
    Ratings:
    +52 / 5 / -0
    Этот код вставляешь в нужное тебе место, если используешь DLE то в файл shortstory.tpl
    Code:
    <img class="js-hover" src='https://img.24video.site/2638/2638147/thumb320_1.jpg' data='https://img.24video.site/2638/2638147/thumb320_2.jpg,https://img.24video.site/2638/2638147/thumb320_3.jpg,https://img.24video.site/2638/2638147/thumb320_3.jpg'>
    В src='Доп поле основного фото' а в data='вставляешь фото уже которое будет Анимация Через запятую'

    И Js код вставить в любой js файл используемый шаблоном

    Code:
    $(function() {
        $('.js-hover').hover(function() {
            var _this = this,
                images = _this.getAttribute('data').split(','),
                counter = 0;
    
            this.setAttribute('data-src', this.src);
            _this.timer = setInterval(function(){
                if(counter > images.length) {
                    counter = 0;
                }
                if (images[counter] != undefined) {
                    _this.src = images[counter];
                } else {
                    _this.src = _this.getAttribute('data-src');
                }
    
                counter++;
            }, 750);
    
        }, function() {
            this.src = this.getAttribute('data-src');
            clearInterval(this.timer);
        });
    });
     
    • Нравится Нравится x 1
  7. TopicStarter Overlay
    iroder

    iroder Бывалый

    Joined:
    Jun 7, 2015
    Messages:
    265
    Best Answers:
    0
    Ratings:
    +35 / 12 / -0
    upload все так и сделал, но почему-то не меняет.

    11.PNG

    22.PNG
     
  8. upload

    PRO Users

    Joined:
    Nov 9, 2016
    Messages:
    208
    Best Answers:
    3
    Ratings:
    +52 / 5 / -0
    iroder
    Попробуй установить js перед закрывающим тегом </body>
    Code:
    <script type="text/javascript">
        $(function() {
        $('.js-hover').hover(function() {
            var _this = this,
                images = _this.getAttribute('data').split(','),
                counter = 0;
            this.setAttribute('data-src', this.src);
            _this.timer = setInterval(function(){
                if(counter > images.length) {
                    counter = 0;
                }
                if (images[counter] != undefined) {
                    _this.src = images[counter];
                } else {
                    _this.src = _this.getAttribute('data-src');
                }
                counter++;
            }, 750);
        }, function() {
            this.src = this.getAttribute('data-src');
            clearInterval(this.timer);
        });
    });
    </script>
    также у тебя должна быть Подключёна "jquery"
     
  9. TopicStarter Overlay
    iroder

    iroder Бывалый

    Joined:
    Jun 7, 2015
    Messages:
    265
    Best Answers:
    0
    Ratings:
    +35 / 12 / -0
    upload Спасибо вам огромное, получилось. Установил js перед закрывающим тегом </body> и все заработал.
     
Яндекс.Метрика