Realization of bullet frame flicker by setinterval method

Time:2021-7-28

Every time I see the puzzle prompt of an e-commerce platform, I feel very interesting and convenient. I happen to be learning a small program, so I think of a way to achieve this effect~

After thinking about it, I still think it’s easier to use setintercal method (I won’t consider the data first. I’ll only do the performance effect here). The basic idea is to control the appearance and hiding of collage prompts through timing; That is, the data transmitted from data to Wx: if is inverted (Boolean value) every certain time; After writing, I seriously compared it. Why are they all flashing? How can I see it more and more awkward

Above [nervous face]

Realization of bullet frame flicker by setinterval method

code:

wxml

<view class="invite_container" wx:if="{{show}}">
        <navigator class="invitation" animation="{{animationData}}" url="../invitation/invitation">
            <view class="invite invite_pic">
                <image></image>
            </view>
            <view class="invite invite_ Content "> lesta invites you to chop your hands together < / View >
        </navigator>
    </view>

js

//In data, the default collage prompt is displayed
    data: {
        show: true,
    }
    
    .......
    //Call the setinterval method in the onload function
    onLoad: function() {
        var that = this;
        //Animation
        var animation = wx.createAnimation();
        //Timing, pop up every 1.5 seconds
        setInterval(function () {
            //Invert control display and hide
            var show = !that.data.show;
            that.setData({
                animationData: animation.export(),
                show: show
            })
        }, 1500)
    }

That’s about it. It’s a simple little method. If you have questions about setinterval, you can go and have a lookReference manualOh.

Attachment: Minegithubaddress

        mySmall projectaddress

Thank you guys~

Realization of bullet frame flicker by setinterval method

Recommended Today

VBS obtains the operating system and its version number

VBS obtains the operating system and its version number ? 1 2 3 4 5 6 7 8 9 10 11 12 ‘************************************** ‘*by r05e ‘* operating system and its version number ‘************************************** strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _  & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _  (“Select * from […]