Skip to content

Commit

Permalink
Upgraded main library and added
Browse files Browse the repository at this point in the history
```js
photoSphereRef.current.getCurrentNavbar()
```
  • Loading branch information
Elius94 committed Oct 7, 2022
1 parent 153f0cf commit 4318b2a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# react-photo-sphere-viewer
> Photosphere Viewer for React.JS
![Screenshot](https://user-images.githubusercontent.com/14907987/180764341-a23c8eec-95c4-4294-bd1c-dc686e53df9a.png)
![Screenshot](https://user-images.githubusercontent.com/14907987/194562000-0411b51e-f017-468a-a51c-c6ce6df9b629.png)


```bash
Expand Down
Binary file modified example/public/Test_Pano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function App() {
});
}

React.useEffect(() => {
console.log(photoSphereRef.current.getCurrentNavbar())
}, []);

return (
<div className="App">
<ReactPhotoSphereViewer ref={photoSphereRef} src="Test_pano.jpg" littlePlanet={true} height={'100vh'} width={"100%"} onClick={handleClick}></ReactPhotoSphereViewer>
Expand Down
28 changes: 17 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-photo-sphere-viewer",
"version": "2.1.2",
"version": "2.1.3",
"description": "Photosphere Viewer for React.JS, wrapper of photo-sphere-viewer.js",
"author": "Elius94",
"license": "MIT",
Expand All @@ -25,7 +25,7 @@
"dependencies": {
"autoprefixer": "^10.4.7",
"eventemitter3": "^4.0.7",
"photo-sphere-viewer": "^4.7.2"
"photo-sphere-viewer": "^4.7.3"
},
"peerDependencies": {
"prop-types": "^15.5.4",
Expand Down
14 changes: 10 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const ReactPhotoSphereViewer = forwardRef((options: Props, ref: any): React.Reac
const [LITTLEPLANET_DEF_LAT] = useState(-90)
const [LITTLEPLANET_FISHEYE] = useState(2)
const [LITTLEPLANET_DEF_ZOOM] = useState(0)
const [currentNavbar, setCurrentNavbar] = useState<(string | object)[]>(defaultNavbar)

useEffect(() => {
function handleResize() {
Expand Down Expand Up @@ -117,7 +118,6 @@ const ReactPhotoSphereViewer = forwardRef((options: Props, ref: any): React.Reac
moveInertia: options.moveInertia || true,
mousewheel: options.littlePlanet ? false : options.mousewheel || true,
mousemove: options.mousemove || true,
captureCursor: options.captureCursor || false,
mousewheelCtrlKey: options.mousewheelCtrlKey || false,
touchmoveTwoFingers: options.touchmoveTwoFingers || false,
useXmpData: options.useXmpData || true,
Expand Down Expand Up @@ -194,9 +194,12 @@ const ReactPhotoSphereViewer = forwardRef((options: Props, ref: any): React.Reac
})
},
}
const currentNavbar: any[] = options.navbar || defaultNavbar
currentNavbar.push(resetLittlePlanetButton)
_c.setOption("navbar", currentNavbar)
const _currentNavbar: any[] = options.navbar || defaultNavbar
if (!_currentNavbar.find((item) => item.id === "resetLittlePlanetButton")) {
_currentNavbar.push(resetLittlePlanetButton)
_c.setOption("navbar", _currentNavbar)
setCurrentNavbar(_currentNavbar)
}
}

Emitter.on("animate", (options: AnimateOptions) => {
Expand Down Expand Up @@ -243,6 +246,9 @@ const ReactPhotoSphereViewer = forwardRef((options: Props, ref: any): React.Reac
setOptions(options: ViewerOptions): void {
return spherePlayerInstance?.setOptions(options)
},
getCurrentNavbar(): (string | object)[] {
return currentNavbar
},
zoom(value: number) {
Emitter.emit("zoom", value)
},
Expand Down
3 changes: 2 additions & 1 deletion src/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ExampleComponent from './'
/*import ExampleComponent from './'
describe('ExampleComponent', () => {
it('is truthy', () => {
expect(ExampleComponent).toBeTruthy()
})
})
*/

0 comments on commit 4318b2a

Please sign in to comment.