Comments (10)
@nerijusgood Do you have a <canvas id="canvas-basic"></canvas>
set in your HTML?
I think the error is due to the fact that your options.element
don't aim a <canvas>
element.
from granim.js.
Yeah I know, I wasn't very clear in my last comment but is the element in
the DOM when the Granim instance is intiated?
Le 15 sept. 2016 9:42 PM, "Pranay Prakash" [email protected] a
écrit :
@sarcadass https://github.com/sarcadass It's a little different with
React since he isn't directly writing HTML, rather using JSX and getting
React to render these dynamically into the DOM—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACVse-Db3tCMM8rNOn4nlGYjDZCPEBAsks5qqZ-6gaJpZM4J90xe
.
from granim.js.
@nerijusgood I'm gonna close this issue since it's not directly related to the codebase, but let's continue this conversation on gitter
from granim.js.
Could you please show me an example snippet of your code?
from granim.js.
Thats what I did. I even tried with event listener:
componentDidMount() {
window.addEventListener('load', this.handleBgEffects.bind(this))
}
handleBgEffects() {
const granimInstance = new Granim({
element: '#canvas-basic',
name: 'basic-gradient',
direction: 'left-right',
opacity: [1, 1],
isPausedWhenNotInView: true,
states: {
'default-state': {
gradients: [
['#AA076B', '#61045F'],
['#02AAB0', '#00CDAC'],
['#DA22FF', '#9733EE'],
],
},
},
})
granimInstance()
}
from granim.js.
I don't believe you need an event listener for this. You also shouldn't invoke the instance directly. If I'm right, it should be pretty straightforward.
Try something like this and let me know if it works:
componentDidMount() {
this.handleBgEffects();
}
handleBgEffects() {
this.granimInstance = new Granim({
element: '#canvas-basic',
name: 'basic-gradient',
direction: 'left-right',
opacity: [1, 1],
isPausedWhenNotInView: true,
states: {
'default-state': {
gradients: [
['#AA076B', '#61045F'],
['#02AAB0', '#00CDAC'],
['#DA22FF', '#9733EE'],
],
},
},
})
}
from granim.js.
Still same issue:
Dynamic page loading failed TypeError: this.canvas.getContext is not a function(…)
from granim.js.
Is this componentDidMount
in the same class that is rendering '#canvas-basic'?
from granim.js.
@sarcadass It's a little different with React since he isn't directly writing HTML, rather using JSX and getting React to render these dynamically into the DOM
from granim.js.
@sarcadass you are right - I actually needed specifically use it on canvas element. I actually used regular div.
It works perfect with <canvas id="canvas-basic"></canvas>
Thank you.
from granim.js.
Related Issues (20)
- Fully dispose Granim to avoid memory leak in SPA HOT 3
- Use on other elements (not canvas) HOT 1
- Using on repeated elements HOT 1
- Change defaultStateName based on page HOT 1
- Feature request - Add easing options HOT 1
- "Uncaught TypeError: Cannot read property 'getElement' of null" Vue.js 2 - nuxt HOT 2
- Can't run the local server for the docs - contributing HOT 2
- Can we change de transitionSpeed dynamically? HOT 2
- HSLA support? HOT 2
- Glitch on Safari when the Canvas is updated too often/quickly HOT 4
- Just for to understand! HOT 1
- How to add more background images like slides HOT 1
- Angular integration HOT 2
- Thanks! HOT 1
- Change state on scroll HOT 1
- Feature request: dynamically change gradients
- Improving performance HOT 1
- 作者怎么可以联系到你 HOT 1
- Something wrong in vue3 HOT 1
- Use in Pure Node Js Script
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from granim.js.