Bonjour !

J'ai un gros soucis avec prestashop et la bibliothèque Fabric JS.

Je n'arrive pas à déplacer une image à l'intérieur d'un canvas, mais uniquement sous prestashop. Le même code sur un codepen.io fonctionne parfaitement.

Je poste le fameux codepen pour que vous puissiez voir, mais c'est très basique. Je pense que quelque chose dans Presta m'empeche de sélectionner quoique ce soit dans un canvas

https://codepen.io/beubz/pen/abLLomw

La seule différence avec ce pen, c'est l'utilisation de balises <script> sur presta, je galère avec le JS donc j'utilise que ça.

Merci!

3 réponses


Gulivert
Réponse acceptée

Hello,
As-tu une erreur sur Presta ? La lib Fabric tu l'as bien chargée avant d'init ton script ?

beubz
Auteur

Hey !
Merci de ta réponse
Pas d'erreur à priori sur presta, la librairie est chargée dans themes/classic/templates/_partials/javascript.tpl
<script src="https://unpkg.com/fabric@4.6.0/dist/fabric.js" charset="utf-8"></script>
J'ai remarqué des petites choses dans la console Google

VM833 fabric.js:9386 Uncaught TypeError: fabric.util.requestAnimFrame is not a function
at klass.requestRenderAll (VM833 fabric.js:9386)
at klass.onMouseDown (VM833 fabric.js:13302)
at klass._onMouseDown (VM833 fabric.js:12866)
requestRenderAll @ VM833 fabric.js:9386
__onMouseDown @ VM833 fabric.js:13302
_onMouseDown @ VM833 fabric.js:12866
4VM833 fabric.js:13287 Uncaught TypeError: fabric.util.isTouchEvent is not a function
at klass.
onMouseDown (VM833 fabric.js:13287)
at klass._onMouseDown (VM833 fabric.js:12866)

Ainsi que 

fabric.Point is already defined

(anonymous) @ fabric.js:5314
(anonymous) @ fabric.js:5641
fabric.js:5652 fabric.Intersection is already defined
(anonymous) @ fabric.js:5652
(anonymous) @ fabric.js:5815
fabric.js:5825 fabric.Color is already defined.
(anonymous) @ fabric.js:5825
(anonymous) @ fabric.js:6453
fabric.js:8331 fabric.Shadow is already defined.
(anonymous) @ fabric.js:8331
(anonymous) @ fabric.js:8517
fabric.js:8525 fabric.StaticCanvas is already defined.
(anonymous) @ fabric.js:8525
(anonymous) @ fabric.js:10389
fabric.js:18052 fabric.Line is already defined
(anonymous) @ fabric.js:18052
(anonymous) @ fabric.js:18365
fabric.js:18376 fabric.Circle is already defined.
(anonymous) @ fabric.js:18376
(anonymous) @ fabric.js:18574
fabric.js:18584 fabric.Triangle is already defined
(anonymous) @ fabric.js:18584
(anonymous) @ fabric.js:18669
fabric.js:18680 fabric.Ellipse is already defined.
(anonymous) @ fabric.js:18680
(anonymous) @ fabric.js:18852
fabric.js:18863 fabric.Rect is already defined
(anonymous) @ fabric.js:18863
(anonymous) @ fabric.js:19041
fabric.js:19055 fabric.Polyline is already defined
(anonymous) @ fabric.js:19055
(anonymous) @ fabric.js:19287
fabric.js:19297 fabric.Polygon is already defined
(anonymous) @ fabric.js:19297
(anonymous) @ fabric.js:19362
fabric.js:19377 fabric.Path is already defined
(anonymous) @ fabric.js:19377
(anonymous) @ fabric.js:19739
fabric.js:20510 fabric.Image is already defined.
(anonymous) @ fabric.js:20510
(anonymous) @ fabric.js:21262
fabric.js:25507 fabric.Text is already defined
(anonymous) @ fabric.js:25507
(anonymous) @ fabric.js:27205
theme.js:8524 fabric.Point is already defined
(anonymous) @ theme.js:8524
(anonymous) @ theme.js:8851
theme.js:8862 fabric.Intersection is already defined
(anonymous) @ theme.js:8862
(anonymous) @ theme.js:9025
theme.js:9035 fabric.Color is already defined.
(anonymous) @ theme.js:9035
(anonymous) @ theme.js:9663
theme.js:9671 fabric.StaticCanvas is already defined.
(anonymous) @ theme.js:9671
(anonymous) @ theme.js:11539
theme.js:15063 fabric.Line is already defined
(anonymous) @ theme.js:15063
(anonymous) @ theme.js:15348
theme.js:15359 fabric.Circle is already defined.
(anonymous) @ theme.js:15359
(anonymous) @ theme.js:15521
theme.js:15531 fabric.Triangle is already defined
(anonymous) @ theme.js:15531
(anonymous) @ theme.js:15616
theme.js:15627 fabric.Ellipse is already defined.
(anonymous) @ theme.js:15627
(anonymous) @ theme.js:15774
theme.js:15785 fabric.Rect is already defined
(anonymous) @ theme.js:15785
(anonymous) @ theme.js:15931
theme.js:15946 fabric.Polyline is already defined
(anonymous) @ theme.js:15946
(anonymous) @ theme.js:16168
theme.js:16179 fabric.Polygon is already defined
(anonymous) @ theme.js:16179
(anonymous) @ theme.js:16233
theme.js:16249 fabric.Path is already defined
(anonymous) @ theme.js:16249
(anonymous) @ theme.js:16591
theme.js:17208 fabric.Image is already defined.

Je fourni un screen de ce que ça rend sur mon Presta. L'image se charge bien ,mais je n'ai aucun controle dessus

(https://imgur.com/q48UHap)

beubz
Auteur

Personne n'a de solution? merfci