Jump to content
Search Community

CCSRule plugin always return null

oldbeavr test
Moderator Tag

Go to solution Solved by oldbeavr,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I wanted to use CSSRule plugin to tween some pseudo elements on my webpage.

 

I'm using SASS to write my CSS.

 

My target looks like this :

.home,
.home.do-not-anim{

    #container{

        &:before{....}

    }

}

and my rule like this : 

var rule = CSSRulePlugin.getRule(".home #container:before");

I saw that the rule must match the exact rule of CSS. So i tried to change it with :

var rule = CSSRulePlugin.getRule(".home #container:before, .home.do-not-anim #container:before");

But the result is always the same : 

CSSRulePlugin.min.js:12 Uncaught TypeError: Cannot read property 'length' of null   

I even try to simplify the rule at it's maximum, like this :

var rule = CSSRulePlugin.getRule("#container");

witch is an existing rule in my CSS, but still, Uncaught TypeError......

 

Result is the same when i copy paste the rule in the console...

 

Did i miss something ??

              

Link to comment
Share on other sites

Hmm, it's a pickle. Are you using the latest GSAP and CSSRulePlugin? What OS and browser are you seeing this behaviour? If you're using other Javascript libraries for your site, have you tried a clean page with just GSAP and no other libraries on the page? Just trying to work out if there is a browser issue, compatibility issue, or bug in GSAP causing this.

 

It's harder to pinpoint an error from the console when you're using the minified file. It's recommended to only use minified files for production sites, and use the original JavaScript during development for easier debugging so you can pinpoint the offending code easily.

 

Lastly, could you set up a reduced Codepen or other online demo so we could take a look? For example, here's a working Codepen of a CSSRulePlugin tween

See the Pen ibHAt by jamiejefferson (@jamiejefferson) on CodePen

  • Like 2
Link to comment
Share on other sites

Hi,

 

Thanks for your quick reply

 

here is a codepen link:

 

See the Pen VYmZYa by anon (@anon) on CodePen

 

About minified version : I tried with the original version, to see what happened. The error occured et line 59 : 'j = curSS.length;'

I've download the zip file from the site.

 

The minified version was taken on the CDN.

 

Other libraries used on the site are : Modernizr & jquery. Both disabled, with no changes :/

 

I'll try on a clean page

 

And, i use Chrome, on Windows 7

 

 

EDIT : Ok, it seems to work on the codepen link you provided .. not on mine (missing CSSRuleplugin)

Edited by oldbeavr
Link to comment
Share on other sites

I'm doing local development, your're right, but i use Zend Server (Apache 2.2 & MySQL Server)

 

I'm not loading my CSS via HTTPS. It's loaded via Wordpress.

 

I tried to remove all CSS rules, but not the ones concerned, from my stylesheets (it's a responsive project). But the problem is still there

Link to comment
Share on other sites

Not exactly :)

 

it's a mobile first project, so i use a _base.scss file, where my target is declared, but not declared in any media queries rules. On top of that, i've got two other scss (768 & 1024), where the target might be declared.

But, with grunt, those 3 files are compiled in one single styles.css file.

 

But even by removing the loading part of the media queries, it does not change anything :/

Link to comment
Share on other sites

  • Solution

Damn, i found it !!

 

i was loading a google fonts via a wordpress action. So it was loading a CSS from google fonts server..

 

@Carl : that might be explaining the cross domain alert..

 

 

RHHAAAA, 5 hours lost ! :)

 

 

Is there a way to specify a unique CSS files to use with CSSrule plugin ?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...