Skip to content

Add previewType props to Scene #8

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ dist
.tern-port

*.tsbuildinfo

# Intelij IDE
.idea
1 change: 1 addition & 0 deletions docs/en-us/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Represent krpano scenes
|:--|:--:|:--:|:--|
| name | string | ✅ | Scene name |
| previewUrl | string | | Preview image url, usually a low-quality image |
| previewType | string | | Preview type to use type="grid" |
| content | string | | Directly specify the xml content of the scene tag, other settings will be ignored after use |
| imageTagAttributes | Record | | Set image tag attributes, see the [official documentation](https://krpano.com/docu/xml/#image) for details |
| images | [SceneImage] or SceneImageWithMultires[] | | Define picture to display in the scene. When length > 1, it will trigger [multires](https://krpano.com/examples/?multires) |
Expand Down
8 changes: 5 additions & 3 deletions src/components/Scene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface SceneImageWithMultires {
export interface SceneProps {
name: string;
previewUrl?: string;
previewType?: string;
/** 直接指定scene的xml内容。指定后会忽略其他设置 */
content?: string;
/** image标签的附加属性,仅少部分情况用到 */
Expand All @@ -32,6 +33,7 @@ export interface SceneProps {
export const Scene: React.FC<SceneProps> = ({
name,
previewUrl,
previewType,
imageTagAttributes = {},
images = [],
content,
Expand Down Expand Up @@ -86,12 +88,12 @@ export const Scene: React.FC<SceneProps> = ({
});
}

const previewTag = `<preview ${previewUrl ? `url="${previewUrl}` : ''}
${previewType ? `type="${previewType}` : ''}" />`;
renderer?.setTag('scene', name, {
content:
content ||
`${previewUrl ? `<preview url="${previewUrl}" />` : ''}${
images.length > 0 ? buildXML(contentImageMeta) : ''
}`,
`${previewUrl || previewType ? previewTag : ''} ${images.length > 0 ? buildXML(contentImageMeta) : ''}`,
});

return () => {
Expand Down