All Projects → alimozdemir → fabric-history

alimozdemir / fabric-history

Licence: MIT license
Fabric.js history plugin

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fabric-history

clifm
The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell
Stars: ✭ 825 (+806.59%)
Mutual labels:  plugins
forgejs-plugins
Plugins for the ForgeJS WebVR framework.
Stars: ✭ 22 (-75.82%)
Mutual labels:  plugins
user-profile-plugin-adobe-xd
User Profile plugin for Adobe XD enables designers to displays beautiful generated avatars 📸 in your design prototype
Stars: ✭ 17 (-81.32%)
Mutual labels:  plugins
helix-plugins
github.com/Bilwin/helix-plugins
Stars: ✭ 24 (-73.63%)
Mutual labels:  plugins
envelop
Envelop is a lightweight library allowing developers to easily develop, share, collaborate and extend their GraphQL execution layer. Envelop is the missing GraphQL plugin system.
Stars: ✭ 630 (+592.31%)
Mutual labels:  plugins
plugin-Authenticator
2FA authentication plugin for sysPass based on TOTP algorithm (RFC 6238)
Stars: ✭ 18 (-80.22%)
Mutual labels:  plugins
pMix2
pMix - a preset interpolator, plug-in chainer and Faust IDE written with JUCE
Stars: ✭ 84 (-7.69%)
Mutual labels:  plugins
ck
Portable automation meta-framework to manage, describe, connect and reuse any artifacts, scripts, tools and workflows on any platform with any software and hardware in a non-intrusive way and with minimal effort. Try it using this tutorial to modularize and automate ML Systems benchmarking from the Student Cluster Competition at SC'22:
Stars: ✭ 501 (+450.55%)
Mutual labels:  plugins
gradle-dependencies-plugins-helper-plugin
This is an IntelliJ IDEA plugin for searching dependencies/plugins from JCentral/GradlePlugins inside Gradle projects.
Stars: ✭ 33 (-63.74%)
Mutual labels:  plugins
fabricjs-psbrush
Fabric.js用の感圧ブラシ実装 / A lightweight pressure-sensitive brush implementation for Fabric.js
Stars: ✭ 45 (-50.55%)
Mutual labels:  fabricjs
kong-js-pdk
Kong PDK for Javascript and plugin server
Stars: ✭ 28 (-69.23%)
Mutual labels:  plugins
plugins
Collection of plugins for Windi CSS.
Stars: ✭ 64 (-29.67%)
Mutual labels:  plugins
ocsinventory
📚 Curso GRÁTIS OCS Inventory NG e GLPI Help Desk REPOSITÓRIO CONGELADO - Esse repositório não irá mais receber atualizações.
Stars: ✭ 58 (-36.26%)
Mutual labels:  plugins
TuubesCore
Scalable server engine for voxel / cubic games
Stars: ✭ 48 (-47.25%)
Mutual labels:  plugins
Flow.Launcher.PluginsManifest
Community-made plugins and submissions
Stars: ✭ 13 (-85.71%)
Mutual labels:  plugins
umeng analytics push
Umeng Analytics&Push Flutter Plugins
Stars: ✭ 28 (-69.23%)
Mutual labels:  plugins
DtBlkFx
Fast-Fourier-Transform (FFT) based VST plug-in
Stars: ✭ 99 (+8.79%)
Mutual labels:  plugins
clappr-plugins
Main plugins for the Clappr project
Stars: ✭ 22 (-75.82%)
Mutual labels:  plugins
audit-log-plugin
Audit logging plugin for Jenkins based on Apache Log4j Audit
Stars: ✭ 19 (-79.12%)
Mutual labels:  plugins
remove-files-webpack-plugin
A plugin for webpack that removes files and folders before and after compilation.
Stars: ✭ 48 (-47.25%)
Mutual labels:  plugins

fabric-history

npm npm

Fabric.js history implementation

Setup

Node projects

npm i fabric-history
import 'fabric-history';

HTML

<script src="https://raw.githubusercontent.com/lyzerk/fabric-history/master/src/index.js"></script>

Usage

Following commands will undo and redo the canvas.

canvas.undo();

canvas.redo();

Example (only for demo purposes)

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Fabric with history</title>
</head>
<body>
  <canvas style="border:1px solid black;" width="800" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.4.0/fabric.min.js"></script>
  <script src="https://alimozdemir.com/fabric-history/src/index.js"></script>

  <script>
    const canvas = new fabric.Canvas(document.querySelector('canvas'), {
      isDrawingMode: true
    })

    document.addEventListener('keyup', ({ keyCode, ctrlKey } = event) => {
      // Check Ctrl key is pressed.
      if (!ctrlKey) {
        return
      }

      // Check pressed button is Z - Ctrl+Z.
      if (keyCode === 90) {
        canvas.undo()
      }

      // Check pressed button is Y - Ctrl+Y.
      if (keyCode === 89) {
        canvas.redo()
      }
    })
    </script>
</body>
</html>

You can find an advanced example on demo folder.

Events

  • history:append
    • Fired when a history appended to stack
  • history:undo
    • Fired when an undo process is happening
  • history:redo
    • Fired when a redo process is happening
  • history:clear
    • Fired when whole history cleared

Callbacks

canvas.undo(function() { 
  console.log('post undo');
});

canvas.redo(function() { 
  console.log('post redo');
});

Functions

  • undo
  • redo
  • clearHistory
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].