fix(demos): fix video-element webcam moveTo error on Fabric 6#357
Open
kiranparajuli589 wants to merge 1 commit into
Open
fix(demos): fix video-element webcam moveTo error on Fabric 6#357kiranparajuli589 wants to merge 1 commit into
kiranparajuli589 wants to merge 1 commit into
Conversation
Signed-off-by: Kiran Parajuli <39373750+kiranparajuli589@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The video-element demo throws
TypeError: webcam.moveTo is not a functionafter the user grants camera permission, leaving the webcam preview black.
fabric.Object#moveTo(index)was removed in Fabric 6 (per-object stackingmoved to canvas methods). The demo runs under two Fabric versions:
_layouts/demo.htmlloadslib/fabric.js) —moveToworks._includes/codepen.htmlloadsfabric@latest) and the new fabricjs.com —moveTothrows.Fix
Feature-detect the API so the demo works under both versions: use
canvas.sendObjectToBack(webcam)when available (Fabric 6+), otherwise fallback to
webcam.moveTo(0)(Fabric 5).sendObjectToBackis the exact v6equivalent of
moveTo(0).Only
posts/demos/_posts/2014-10-16-video-element.htmlis touched.Testing
jekyll serve, v5.2.1): open/demos/video-element/, grant camera →no console error, webcam renders behind the sample video.
moveToTypeError.Signed-off-by: Kiran Parajuli 39373750+kiranparajuli589@users.noreply.github.com