Jump to content
Search Community

Failed to execute "getComputedStyle" error using SplitText

cstodor test
Moderator Tag

Go to solution Solved by Jonathan,

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

Hey,

 

I would like to create a matrix style code rain with GSAP using the SplitText Utility, but I've encountered an error when following your tutorial video.

 

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.                              SplitText.min.js:15

 

 

not sure what I'm doing wrong... any advice would be appreciated.

See the Pen JKkAam by cstodor (@cstodor) on CodePen

Link to comment
Share on other sites

  • Solution

I did notice something.. is there any reason why your not using document instead of window for your ready event? The window could be ready or loaded, but that does not mean the document is ready or loaded.

 

The standard should first check if the document (DOM) is ready. And then check if the window is loaded. Doing it that way you make sure the DOM is ready and the window (css stylesheets, links, and images) are fully loaded.

// wait until DOM is ready
document.addEventListener("DOMContentLoaded", function(event) {

     // wait until all the window (images, stylesheets, and links) are loaded
     window.onload = function(){

          // code goes here
     
     });
});

:)

  • Like 5
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...