clientIO / joint

A proven SVG-based JavaScript diagramming library powering exceptional UIs
https://jointjs.com
Mozilla Public License 2.0
4.45k stars 841 forks source link

types(dia.Paper): allow disabling allowNewOrigin option #2530

Closed kumilingus closed 2 months ago

kumilingus commented 3 months ago

Description

It's currently not possible to override the allowNewOrigin to its default. This PR makes it possible to pass false for the paper origin to remain at 0,0 in TypeScript.

Note that this has always been possible in JavaScript, and this PR just changes the types and updates the documentation to make it clear.

// before
paper.getFitToContentArea({ allowNewOrigin: 'negative' | 'positive' | 'any'  })

// after
paper.getFitToContentArea({ allowNewOrigin: false | 'negative' | 'positive' | 'any'  })

The problem was evident in the paper scroller.

const scroller = new ui.PaperScroller({
   /* ... */
   contentOptions: {
      allowNewOrigin: false // the paper scroller default for `allowNewOrigin` is `positive`
   }
})