最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Velocity: First Argument was not a property map - Stack Overflow

programmeradmin1浏览0评论

I am using Velocity to do some animations (without jQuery), and I am having an issue where I get the following error:

Velocity: First argument ([object HTMLDivElement]) was not a property map, a known action, or a registered redirect. Aborting.

I have looked at other examples, and they seem to do it the same way I do, and thiers works. Why is mine not working?

When I dump out the value of rev.elem I get a HTMLDivElement

Velocity(rev.elem, 'slideUp', {
    duration: 225,
    queue: false,
    easing: 'easeInOutQuad'
});

This guy seems to use it the same way and it works for him:
/blog/velocity-js-vertical-slide-without-jquery

I am using Velocity to do some animations (without jQuery), and I am having an issue where I get the following error:

Velocity: First argument ([object HTMLDivElement]) was not a property map, a known action, or a registered redirect. Aborting.

I have looked at other examples, and they seem to do it the same way I do, and thiers works. Why is mine not working?

When I dump out the value of rev.elem I get a HTMLDivElement

Velocity(rev.elem, 'slideUp', {
    duration: 225,
    queue: false,
    easing: 'easeInOutQuad'
});

This guy seems to use it the same way and it works for him:
http://jasonweaver.name/blog/velocity-js-vertical-slide-without-jquery

Share Improve this question asked Jan 4, 2017 at 0:32 Get Off My LawnGet Off My Lawn 36.4k46 gold badges198 silver badges376 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

I got it to work by importing both velocity and velocity ui:

import Velocity from 'velocity-animate';
import 'velocity-animate/velocity.ui';

If you're using the beta Velocity V2 then this won't work yet - I removed the shortcuts such as this in favour of an extensible API - I'm working on sequences right now and will return to this answer when they are in there (within the next few weeks).

I have got the example of this up and running...

The example is based on Jason Weaver's original example but has been updated to the latest version of Velocity and has the PUG syntactical error fixed.

  var el = document.querySelector(element), // cache click target
    con = document.querySelector(container), // cache container target
    up = 'slideUp', // store up mand
    down = 'slideDown'; // store down mand

  el.addEventListener('click', function(event) {

    var active = el.classList.contains('active'); // store active state
    el.classList.toggle('active'); // toggle click target active

    Velocity(con, active ? up : down, { // test and init mand
      duration: duration, // duration set in function call params
      easing: easing // easing set in function call params
    });

    event.preventDefault();

});

You need to import both "velocity" and "velocity ui":

<script src="https://cdn.jsdelivr/npm/[email protected]/velocity.js"></script>
<script src="https://cdn.jsdelivr/npm/[email protected]/velocity.ui.min.js"></script>
发布评论

评论列表(0)

  1. 暂无评论