Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
e2b92c15
Commit
e2b92c15
authored
2 years ago
by
dsehnal
Browse files
Options
Downloads
Patches
Plain Diff
PluginContext.initContainer options
parent
14614f48
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
src/mol-plugin-ui/viewport/canvas.tsx
+1
-1
1 addition, 1 deletion
src/mol-plugin-ui/viewport/canvas.tsx
src/mol-plugin/context.ts
+16
-10
16 additions, 10 deletions
src/mol-plugin/context.ts
with
19 additions
and
11 deletions
CHANGELOG.md
+
2
−
0
View file @
e2b92c15
...
@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
...
@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased]
## [Unreleased]
-
Make
`PluginContext.initContainer`
checkered canvas background optional
## [v3.23.0] - 2022-10-19
## [v3.23.0] - 2022-10-19
-
Add
`PluginContext.initContainer/mount/unmount`
methods; these should make it easier to reuse a plugin context with both custom and built-in UI
-
Add
`PluginContext.initContainer/mount/unmount`
methods; these should make it easier to reuse a plugin context with both custom and built-in UI
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin-ui/viewport/canvas.tsx
+
1
−
1
View file @
e2b92c15
...
@@ -38,7 +38,7 @@ export class ViewportCanvas extends PluginUIComponent<ViewportCanvasParams, View
...
@@ -38,7 +38,7 @@ export class ViewportCanvas extends PluginUIComponent<ViewportCanvasParams, View
};
};
componentDidMount
()
{
componentDidMount
()
{
if
(
!
this
.
container
.
current
||
!
this
.
plugin
.
mount
(
this
.
container
.
current
!
))
{
if
(
!
this
.
container
.
current
||
!
this
.
plugin
.
mount
(
this
.
container
.
current
!
,
{
checkeredCanvasBackground
:
true
}
))
{
this
.
setState
({
noWebGl
:
true
});
this
.
setState
({
noWebGl
:
true
});
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/context.ts
+
16
−
10
View file @
e2b92c15
...
@@ -193,7 +193,7 @@ export class PluginContext {
...
@@ -193,7 +193,7 @@ export class PluginContext {
*/
*/
readonly
customState
:
unknown
=
Object
.
create
(
null
);
readonly
customState
:
unknown
=
Object
.
create
(
null
);
initContainer
(
canvas3dContext
?:
Canvas3DContext
)
{
initContainer
(
options
?:
{
canvas3dContext
?:
Canvas3DContext
,
checkeredCanvasBackground
?:
boolean
}
)
{
if
(
this
.
canvasContainer
)
return
true
;
if
(
this
.
canvasContainer
)
return
true
;
const
container
=
document
.
createElement
(
'
div
'
);
const
container
=
document
.
createElement
(
'
div
'
);
...
@@ -209,27 +209,33 @@ export class PluginContext {
...
@@ -209,27 +209,33 @@ export class PluginContext {
'
-webkit-touch-callout
'
:
'
none
'
,
'
-webkit-touch-callout
'
:
'
none
'
,
'
touch-action
'
:
'
manipulation
'
,
'
touch-action
'
:
'
manipulation
'
,
});
});
let
canvas
=
canvas3dContext
?.
canvas
;
let
canvas
=
options
?.
canvas3dContext
?.
canvas
;
if
(
!
canvas
)
{
if
(
!
canvas
)
{
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
=
document
.
createElement
(
'
canvas
'
);
Object
.
assign
(
canvas
.
style
,
{
if
(
options
?.
checkeredCanvasBackground
)
{
'
background-image
'
:
'
linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey), linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey)
'
,
Object
.
assign
(
canvas
.
style
,
{
'
background-size
'
:
'
60px 60px
'
,
'
background-image
'
:
'
linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey), linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey)
'
,
'
background-position
'
:
'
0 0, 30px 30px
'
'
background-size
'
:
'
60px 60px
'
,
});
'
background-position
'
:
'
0 0, 30px 30px
'
});
}
container
.
appendChild
(
canvas
);
container
.
appendChild
(
canvas
);
}
}
if
(
!
this
.
initViewer
(
canvas
,
container
,
canvas3dContext
))
{
if
(
!
this
.
initViewer
(
canvas
,
container
,
options
?.
canvas3dContext
))
{
return
false
;
return
false
;
}
}
this
.
canvasContainer
=
container
;
this
.
canvasContainer
=
container
;
return
true
;
return
true
;
}
}
mount
(
target
:
HTMLElement
)
{
/**
* Mount the plugin into the target element (assumes the target has "relative"-like positioninig).
* If initContainer wasn't called separately before, initOptions will be passed to it.
*/
mount
(
target
:
HTMLElement
,
initOptions
?:
{
canvas3dContext
?:
Canvas3DContext
,
checkeredCanvasBackground
?:
boolean
})
{
if
(
this
.
disposed
)
throw
new
Error
(
'
Cannot mount a disposed context
'
);
if
(
this
.
disposed
)
throw
new
Error
(
'
Cannot mount a disposed context
'
);
if
(
!
this
.
initContainer
())
return
false
;
if
(
!
this
.
initContainer
(
initOptions
))
return
false
;
if
(
this
.
canvasContainer
!
.
parentElement
!==
target
)
{
if
(
this
.
canvasContainer
!
.
parentElement
!==
target
)
{
this
.
canvasContainer
!
.
parentElement
?.
removeChild
(
this
.
canvasContainer
!
);
this
.
canvasContainer
!
.
parentElement
?.
removeChild
(
this
.
canvasContainer
!
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment