iT邦幫忙

0

如何網頁下拉區塊移動

  • 分享至 

  • xImage

_各位大大好:

想請問如何下面首頁有三個區塊滑到時,區塊自動跑出來,謝謝

這好像是視差滾動嗎?

https://www.epadesign.tw/

看更多先前的討論...收起先前的討論...
註冊單 iT邦新手 4 級 ‧ 2019-03-16 13:50:05 檢舉
網站特效 你查他的語法就知道
註冊單 iT邦新手 4 級 ‧ 2019-03-16 13:51:06 檢舉
他有搭配Jquery
iT邦新手 5 級 ‧ 2019-03-16 18:31:00 檢舉
寫在回答比較好閱讀~~
mayyola iT邦研究生 1 級 ‧ 2019-03-16 19:16:06 檢舉
感覺好難,有關鍵字可以搜尋這種方法是什麼嗎?
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
iT邦新手 5 級 ‧ 2019-03-16 18:46:23
最佳解答

**先討論一下思路:這三個區塊會滑出來,可能是游標指到某一個元素時觸發函式,
這通常會使用javascript。
因此你可以看他自己寫的 https://www.epadesign.tw/__system/__js/h_abe9b35c322da2001b506ae8e969b269/2285042_combined.min.js 這一隻js,
我挑出幾個關鍵的function如下,您可以研究看看,謝謝。

1.主要使用的函式是 ivfx_fade_in :**

(jQuery), function (i) {
        i.fn.ivfx_fade_in = function (t) {
            return this.each(function () {
                new jQuery.ivfx_fade_in(this, t)
            })
        }, i.fn.ivfx_fade_in_activate = function () {
            return this.each(function () {
                jQuery.data(this, "ivfx_fade_in").activate()
            })
        }, i.fn.ivfx_fade_in_deactivate = function () {
            return this.each(function () {
                jQuery.data(this, "ivfx_fade_in").deactivate()
            })
        }, i.fn.ivfx_fade_in_editor_activate = function () {
            return this.each(function () {
                jQuery.data(this, "ivfx_fade_in").editor_activate()
            })
        }, i.fn.ivfx_fade_in_editor_deactivate = function () {
            return this.each(function () {
                jQuery.data(this, "ivfx_fade_in").editor_deactivate()
            })
        }, i.ivfx_fade_in = function (t, e) {
            i.data(t, "ivfx_fade_in", this), e = i.extend({
                id: t.id,
                $ele: i(t),
                name: "ivfx_fade_in",
                events: {
                    top: ["scroll", "orientationchange"],
                    bottom: ["scroll", "orientationchange"]
                },
                inline_styles: {
                    transform: !0,
                    "transform-style": !0,
                    position: !0,
                    opacity: !0
                },
                styles_on_activate: {
                    top: {
                        opacity: 0
                    },
                    bottom: {
                        opacity: 0
                    }
                }
            }, e), this.options = e, i.ivfx.register_effect(this), i.ivfx_tweenmax.register_effect(this);
            var l = this,
                c = l.$ele;
            return this.set_parameters = function () {
                l._params.direction = "none", l._params.trigger_event = "top", l._params.duration = 1, l._params.delay = 0, l._params.bring_to_front = "1", l._params.will_reset_at_top = !1, l._params.easing = "Linear.easeNone";
                var t = l.refresh_selected_breakpoint(),
                    e = !!t && t.params;
                e && (-1 !== i.inArray(e.__direction, ["none", "left", "right", "up", "down"]) && (l._params.direction = e.__direction), 0 == e.__bring_to_front && (l._params.bring_to_front = "0"), 1 == e.__will_reset_at_top && (l._params.will_reset_at_top = !0), e.__easing && (l._params.easing = e.__easing), l.is_number(e.__duration) && (l._params.duration = e.__duration), l.is_number(e.__delay) && (l._params.delay = e.__delay), e.__trigger_event && (l._params.trigger_event = e.__trigger_event))
            }, this.create_tween = function (t) {
                if (t = t || {}, l.is_tween_playing) return !1;
                var e = t.duration || l._params.duration,
                    i = {
                        startAt: {
                            opacity: 0
                        },
                        delay: t.delay || l._params.delay,
                        opacity: 1,
                        ease: l._params.easing,
                        onStart: function () {
                            l.is_tween_playing = !0, 1 == l._params.bring_to_front && l.bring_to_front()
                        }, onComplete: function () {
                            l.is_tween_playing = !1
                        }
                    },
                    n = (c.css("position"), l.first_relative_parent(c)),
                    r = l.element_bounding_rect(n),
                    a = l.element_bounding_rect(c),
                    s = a.left - r.left,
                    o = a.top - r.top;
                switch (l._params.direction) {
                case "left":
                    "none" == c.css("transform") ? (i.startAt.x = "50%", i.x = "0%") : (i.startAt.marginLeft = 0, i.startAt.marginRight = 0, i.startAt.x = 0, i.startAt.left = s + 200, i.left = s);
                    break;
                case "right":
                    "none" == c.css("transform") ? (i.startAt.x = "-50%", i.x = "0%") : (i.startAt.marginLeft = 0, i.startAt.marginRight = 0, i.startAt.x = 0, i.startAt.left = s - 200, i.left = s);
                    break;
                case "up":
                    "none" == c.css("transform") ? (i.startAt.y = "50%", i.y = "0%") : (i.startAt.marginTop = 0, i.startAt.marginBottom = 0, i.startAt.y = 0, i.startAt.top = o + 200, i.top = o);
                    break;
                case "down":
                    "none" == c.css("transform") ? (i.startAt.y = "-50%", i.y = "0%") : (i.startAt.marginTop = 0, i.startAt.marginBottom = 0, i.startAt.y = 0, i.startAt.top = o - 200, i.top = o)
                }
                l.tween = new TweenMax(c[0], e, i)
            }, l.auto_init({
                no_wait: !0
            }), this
        }
    }

2.三個區塊ID如下:
rot_ctr1_bod_ctr2_bod_wrp1_blk3_custom_blk1_custom_blk1_custom
rot_ctr1_bod_ctr2_bod_wrp1_blk3_custom_blk1_custom_blk2_custom
rot_ctr1_bod_ctr2_bod_wrp1_blk3_custom_blk1_custom_blk3_custom

jQuery("#rot_ctr1_bod_ctr2_bod_wrp1_blk3_custom_blk1_custom_blk1_custom").ivfx_fade_in({
        class: "ivfx_fade_in",
        breakpoint_params: {
            770: {
                name: "phablet",
                params: {
                    __easing: "Back.easeOut",
                    __bring_to_front: "0",
                    __direction: "down"
                },
                width: "770",
                is_enabled: 1
            },
            499: {
                width: "499",
                name: "phone",
                params: {
                    __easing: "Back.easeOut",
                    __direction: "down",
                    __bring_to_front: "0"
                },
                is_enabled: 1
            },
            1e3: {
                is_enabled: 1,
                width: "1000",
                params: {
                    __bring_to_front: "0",
                    __direction: "down",
                    __easing: "Back.easeOut"
                },
                name: "tablet"
            },
            0: {
                width: "0",
                name: "desktop",
                params: {
                    __easing: "Back.easeOut",
                    __direction: "down",
                    __bring_to_front: "0"
                },
                is_enabled: 1
            }
        },
        breakpoints: [0, 1e3, 770, 499]
    }), jQuery("#rot_ctr1_bod_ctr2_bod_wrp1_blk3_custom_blk1_custom_blk2_custom").ivfx_fade_in({
        breakpoints: [0, 1e3, 770, 499],
        breakpoint_params: {
            1e3: {
                is_enabled: 1,
                name: "tablet",
                params: {
                    __easing: "Back.easeOut",
                    __delay: "0.3",
                    __bring_to_front: "0",
                    __direction: "down"
                },
                width: "1000"
            },
            0: {
                is_enabled: 1,
                width: "0",
                params: {
                    __easing: "Back.easeOut",
                    __delay: "0.3",
                    __bring_to_front: "0",
                    __direction: "down"
                },
                name: "desktop"
            },
            770: {
                is_enabled: 1,
                width: "770",
                name: "phablet",
                params: {
                    __easing: "Back.easeOut",
                    __delay: "0.3",
                    __bring_to_front: "0",
                    __direction: "down"
                }
            },
            499: {
                is_enabled: 1,
                width: "499",
                params: {
                    __delay: "0.3",
                    __easing: "Back.easeOut",
                    __direction: "down",
                    __bring_to_front: "0"
                },
                name: "phone"
            }
        },
        class: "ivfx_fade_in"
    }), jQuery("#rot_ctr1_bod_ctr2_bod_wrp1_blk3_custom_blk1_custom_blk3_custom").ivfx_fade_in({
        breakpoints: [0, 1e3, 770, 499],
        class: "ivfx_fade_in",
        breakpoint_params: {
            1e3: {
                is_enabled: 1,
                params: {
                    __delay: "0.6",
                    __easing: "Back.easeOut",
                    __direction: "down",
                    __bring_to_front: "0"
                },
                name: "tablet",
                width: "1000"
            },
            0: {
                is_enabled: 1,
                params: {
                    __direction: "down",
                    __bring_to_front: "0",
                    __delay: "0.6",
                    __easing: "Back.easeOut"
                },
                name: "desktop",
                width: "0"
            },
            499: {
                width: "499",
                params: {
                    __bring_to_front: "0",
                    __direction: "down",
                    __easing: "Back.easeOut",
                    __delay: "0.6"
                },
                name: "phone",
                is_enabled: 1
            },
            770: {
                width: "770",
                params: {
                    __bring_to_front: "0",
                    __direction: "down",
                    __easing: "Back.easeOut",
                    __delay: "0.6"
                },
                name: "phablet",
                is_enabled: 1
            }
        }
    });
mayyola iT邦研究生 1 級 ‧ 2019-03-19 22:58:17 檢舉

謝謝

0
marlin12
iT邦研究生 5 級 ‧ 2019-03-16 22:49:54

這是用lazyload + animate.css做出來的。
Attempt at Lazyload animate.css

mayyola iT邦研究生 1 級 ‧ 2019-03-19 22:59:40 檢舉

謝謝

我要發表回答

立即登入回答