jquery - 平移和缩放图像插件
问题描述
我正在尝试实现像谷歌艺术和文化图像缩放和平移。
我尝试使用ng2-image-viewer库,但似乎无法解决。
以下是我尝试过的片段。
<app-image-viewer
[images]="['https://images.nga.gov/en/web_images/niagara2.jpg']"
[loadOnInit]="true"
[idContainer]="'idOnHTML'">
</app-image-viewer>
结果:
如您所见,图像在预期区域上方,不是适当的控件,也不是为我们提供小地图的那个小矩形。
解决方案
按照这个:
1- 要安装此库,请运行:
npm install iv-viewer
npm install ng2-image-viewer
2- 在 AppModule 中
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { ImageViewerModule } from 'ng2-image-viewer';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Specify your library as an import
ImageViewerModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
3- 现在只需在 angular-cli.json 文件中添加这些代码:
"styles": [
"../node_modules/ng2-image-viewer/imageviewer.scss"
],
4- 导入库后,您可以在 Angular 应用程序中使用其组件、指令和管道:
<!-- You can now use your library component in app.component.html -->
<h1>
Image Viewer
</h1>
<app-image-viewer [images]="['https://picsum.photos/900/500/?random', 'https://picsum.photos/900/500/?random', 'https://picsum.photos/900/500/?random']"
[idContainer]="'idOnHTML'"
[loadOnInit]="true"></app-image-viewer>
推荐阅读
- python - 如何使用 arg 解析器库从参数传递的文件中打印第一行
- kotlin - Dagger 2 public field injection 产生“private field injection”错误
- c - 我不明白为什么打印带有变量的函数值时输出不同
- jetty - 如何防止战争库 slf4j 与我的项目 slf4j 发生冲突?
- flutter - 如何使用 3 个参数创建获取请求?
- twitter-bootstrap-3 - Zikula 在 Bootstrap 主题中将块添加到顶部导航位置
- python - 在pytest中,如何断言是否引发了异常(从父异常类继承)?
- c# - 有没有办法在 C# WinForm 中更快地加载哪个 BackColor = 透明控件?
- c# - 在 SignalR 中使用基类
- python-3.x - 外部触发具有 schedule_interval=None 的 dag