Code Monkey home page Code Monkey logo

tailwindsjs's Introduction

tailwindsjs's People

Contributors

ianrandmckenzie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

redhawk18

tailwindsjs's Issues

`to-anim` and `from-anim` get confused if multiple groups are applied

In a scenario such as tabs with 3 or more tabs, all tabs would need to have the group class for all tab buttons.

However, this starts to make the class attribute more bloated than it already could be in TailwindCSS.

So, a solution is either:

  1. Simply let the class attribute get bloated from multiconditional animations like Tabs
  2. Create more logic for some kind of class called main-group-anim:[unique_id] where a default like from-anim:hidden and to-anim:block could be applied in a broad stroke where the button overrides the default of from-anim:hidden or something.

Option number 2 would only work for Tabs and Tab-like use-cases. Option number 1 would be a lot more versatile. In that sense, I tend to favor Option 1. On the other hand, Option 2 is a sort-of syntax sugar that would make use cases like Tabs a lot less annoying to implement.

I will think about this.

`toggle-anim`

The issue #2 mentioned syntax sugar. It would definitely be nice to have a toggle-anim if simply toggling to and from a certain state. It may even serve as a better solution for the original existence of #2 in the first place.

Whether it does or not, though, #2 does at least reveal if/else changes need to be solved at some point for more complex use-cases than Tabs.

Uncaught TypeError: element.className.split is not a function

When animating an SVG, I run into the error:
Uncaught TypeError: element.className.split is not a function

Fix:

function animateElement(element) {
  let classNames = null;
  if (element.tagName === 'svg'){
    classNames = element.className.baseVal.split(' ');
  } else {
    classNames = element.className.split(' ');
  }
  let fromClasses = [], toClasses = [];

  // Extract 'from' and 'to' classes
  classNames.forEach(name => {
    if (name.startsWith('from-anim:')) fromClasses.push(name.slice(10)); // remove 'from-anim:'
    if (name.startsWith('to-anim:')) toClasses.push(name.slice(8)); // remove 'to-anim:'
  });

  // Toggle classes
  fromClasses.forEach((fromClass, index) => {
    if (element.classList.contains(fromClass)) {
      element.classList.remove(fromClass);
      element.classList.add(toClasses[index]);
    } else {
      element.classList.remove(toClasses[index]);
      element.classList.add(fromClass);
    }
  });
}

I will add this to the next release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.