Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling canvas.createLayer() programatically doesn't update layers panel #104

Closed
flintobrien opened this issue Apr 25, 2016 · 1 comment · Fixed by #106
Closed

calling canvas.createLayer() programatically doesn't update layers panel #104

flintobrien opened this issue Apr 25, 2016 · 1 comment · Fixed by #106

Comments

@flintobrien
Copy link
Contributor

I'm happy to fix this, just looking to narrow down possible options....

Problem

For our application; on startup of svgedit, we rename "Layer 1" and create a second layer. The layers panel is not repopulated and still shows one layer, "Layer 1" even though the document has been updated correctly.

Analysis

createLayer does issue call('changed', [new_layer]), but the layers panel is looking for change to svg#svgcontent, not the <g> element of the new layer.

Here's the relevant code in svg-editor.js

var elementChanged = function(win, elems) {
  ...
  if (elem && elem.tagName === 'svg') {
    populateLayers();
    updateCanvas();
  }
  ...
}

Possible fixes

  1. Add a class="layer" to the layer group element to identify layers. Then elementChanged can easily identify a layer change. This is clean but not backwards compatible for old documents (unless we add code to update them on load).
  2. In elementChanged, add an additional test for elem.parentNode being svg with id === 'svgcontent' to identify layer changes.
  3. svgedit.draw.Drawing.prototype.identifyLayers could issue a more direct broadcast message to notify the layers panel that the layers have changed. I don't know the repercussions of this.
  4. Other ideas?

From what I currently know, I'd recommend option 2. If I was designing from scratch, I'd pick 1.

@codedread
Copy link
Member

Ok, I will have to try look at the code and think more about this (maybe tonight or tomorrow). I have a gut preference for suggestion #1 with the caveat that documents re-loaded back in would get the class="layer" added like you suggest

AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 24, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 25, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 25, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 25, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 25, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 25, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 27, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 27, 2021
AgriyaDev5 added a commit to OptimistikSAS/svgedit that referenced this issue May 27, 2021
jfhenon added a commit that referenced this issue May 27, 2021
#104 Jquery convert to pure javascript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants