Flex、AngularJS + Masonry、akoenig/angular-deckgrid 等 [重复]

2024-06-02

我一直在发送此电子邮件: 我即将发布一个用于 Web 应用程序安全的应用程序,它需要使用像 Masonry 这样的网格。我已经尝试过所有的、每一个角度模块、指令和不同的方法,包括基于 CSS 的技术、纯 Vanilla JS,而你的解决方案是在线可用的最佳选项之一。然而,我发现一个主要问题,它不仅影响你的方法,而且影响每一个 Angular 模块或插件。

问题#1:

与任何其他解决方案一样,您的解决方案基于已由 Angular 处理的一系列信息。在您的示例中,它将是 source="photos"。现在,当有两组不同的元素时,问题就出现了。假设我有一组先前在 DOM 中定义的元素。换句话说:

<div angular-grid>
    <p class="angular-grid-elem">This content is already here from the beginning, in the DOM, directly in the HTML, and I want to apply a Masonry like style on it.</p>
    <div class="angular-grid-elem" style="height:500px">Same happens with this content.</div>
    <!-- and here comes more content, which is loaded from an array of information -->
    <div class="angular-grid-elem" ng-repeat="data in data_array">
        <p>{{data.header}}</p>
        <p>{{data.details}}</p>
    </div>
</div>

现在,正如您在示例中看到的,主 div 内的内容应该是全部,受砌体布局的影响。当然,这是伪代码,我知道您的方法的语法是不同的。然而,我在这里试图表示的是,如果您能够应用像网格这样的砌体,包括首先已经存在于 DOM/HTML 中的元素,那么您的模块会更好来自数组。

问题#2:

我在多个角度模块和方法中发现了第二个问题。如果我有 2、3 个甚至 16 个 div,它们都呈现相同的砖石行为,会发生什么?我必须承认,我没有尝试使用您的模块,因为我无法解决最初的问题,这需要正确处理以下元素的组合:(1) 在 HTML 中预定义,以及 (2 ) 来自 ng-repeat 函数。

一种可能的方法:

为了解决第二个问题和第一个问题,我同时想到最好的方法可能是利用元素类和元素id来处理这种情况?为什么?因为它可以轻松地应用于 DOM 中已经存在的元素,也可以应用于通过使用 ng-repeat 或任何其他角度函数动态加入或离开的元素。

这是我所说的一个例子:

<div class="angular-grid-dad-one" ng-grid="{'dad': 'angular-grid-dad-one', 'childs': 'angular-grid-elem'}" >
    <p class="angular-grid-elem">This content is already here from the beginning, in the DOM, directly in the HTML, and I want to apply a Masonry like style on it.</p>
    <div class="angular-grid-elem" style="height:500px">Same happens with this content.</div>
    <!-- and here comes more content, which is loaded from an array of information -->
    <div class="angular-grid-elem" ng-repeat="data in data_array">
        <p>{{data.header}}</p>
        <p>{{data.details}}</p>
    </div>
</div>

在这种情况下,主 div 将自身定义为 id="angular-grid-dad-one", 并且还告诉 Angular 模块,元素 angular-grid-dad-one 是一个类似砖石结构的容器 div, 它的孩子被标记为 Angular-Grid-Elem。 正如我们在这条线上看到的。 ng-grid="{'dad': 'angular-grid-dad-one', 'childs': 'angular-grid-elem'}"

这样,我们就可以在多个实例中使用 Angular 模块。例如。

<div class="seccion_01" ng-grid="{'dad': 'seccion_01', 'childs': 'seccion_01_child'}" ng-show="seccion == '1'">
    <p class="seccion_01_child">This content is already here from the beginning, in the DOM, directly in the HTML, and I want to apply a Masonry like style on it.</p>
    <div class="seccion_01_child" style="height:500px">Same happens with this content.</div>
    <!-- and here comes more content, which is loaded from an array of information -->
    <div class="seccion_01_child" ng-repeat="data in data_array">
        <p>{{data.header}}</p>
        <p>{{data.details}}</p>
    </div>
</div>

<div class="another_container" ng-grid="{'dad': 'another_container', 'childs': 'child_of_container'}" ng-show="seccion == '2'">
    <p class="child_of_container">This content is already here from the beginning, in the DOM, directly in the HTML, and I want to apply a Masonry like style on it.</p>
    <div class="child_of_container" style="height:500px">Same happens with this content.</div>
    <!-- and here comes more content, which is loaded from an array of information -->
    <div class="child_of_container" ng-repeat="data in data_array">
        <p>{{data.header}}</p>
        <p>{{data.details}}</p>
    </div>
</div>

<div class="redundant_example" ng-grid="{'dad': 'redundant_example', 'childs': 'childs_of_redundancy'}" ng-show="seccion == '3'">
    <p class="childs_of_redundancy">This content is already here from the beginning, in the DOM, directly in the HTML, and I want to apply a Masonry like style on it.</p>
    <div class="childs_of_redundancy" style="height:500px">Same happens with this content.</div>
    <!-- and here comes more content, which is loaded from an array of information -->
    <div class="childs_of_redundancy" ng-repeat="data in data_array">
        <p>{{data.header}}</p>
        <p>{{data.details}}</p>
    </div>
</div>

我在 ng-grid 值中使用了 Json 风格的指令来解释我的观点,但它不一定是 Json。它甚至可以是两个不同的参数:

<div class="dad" ng-grid-dad="dad" ng-grid-childs="childs" ng-show="seccion == '3'">
    <p class="childs">This content is already here from the beginning, in the DOM, directly in the HTML, and I want to apply a Masonry like style on it.</p>
    <div class="childs" style="height:500px">Same happens with this content.</div>
    <!-- and here comes more content, which is loaded from an array of information -->
    <div class="childs" ng-repeat="data in data_array">
        <p>{{data.header}}</p>
        <p>{{data.details}}</p>
    </div>
</div>

此外,对于您创建的无限滚动,您当然可以加载更多元素,触发无限滚动,并仅加载一个特定数组中的元素。 如果我可以进一步提供帮助,请告诉我,我想将您的模块集成到我的应用程序中。

希望通过 HTML 和 CSS 的下一个实现,下一代浏览器能够完全控制这种情况,我知道用 Javascript 制作这个网格需要做的工作。


事实上,我要冒险说这句话flex-wrap: wrap将解决该问题。

.holder {
flex-wrap: wrap
-moz-columns: 2 auto;
box-sizing: border-box;
display: flex;
padding: 0 40px;
width: 100%;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Flex、AngularJS + Masonry、akoenig/angular-deckgrid 等 [重复] 的相关文章

随机推荐

  • 在 javascript 原型事件处理程序中保留“this”引用[重复]

    这个问题在这里已经有答案了 正确的保存方法是什么this存储在对象原型内的事件处理程序中的 javascript 引用 我不想创建像 this 或 that 这样的临时变量 而且我不能使用像 jQuery 这样的框架 我看到很多人谈论使用
  • char和int相加的结果[重复]

    这个问题在这里已经有答案了 考虑以下代码 System out println G 2 输出是 73 我能知道为什么以及如何做吗 在java中 一个char占用16位UTF 16编码 G s unicode https www rapidt
  • zone.js:140未捕获类型错误:无法读取属性“删除”

    我是 kendo ui 的新手 我在小提琴中开发了原型 删除确认窗口在那里工作正常 但是当我集成到我的代码库中时 我收到错误 Cannot read property remove at the line pai to delete rem
  • putExtra() 和 setData() 之间的区别

    putExtra 和 setData 有什么区别 我已经阅读了 android 文档 但没有太大帮助 还有之前的一个问题Intent setData 与 Intent putExtra https stackoverflow com que
  • 为什么变量被声明为 TStrings 并被创建为 TStringList?

    为什么变量声明为TStrings并创建为TStringList 例如 varsl被声明为TStrings但创建为TStringList var sl TStrings begin sl TStringList Create add stri
  • C中sizeof的内部机制?

    我使用 sizeof 来获取 C 中结构的大小 但得到的结果是意外的 struct sdshdr int len int free char buf int main printf struct len d n sizeof struct
  • Java中的内部类

    我正在学习 Java 中阅读关于内部类的内容 我找到了这段代码 class Animal class Brain 编译后 javap Animal Brain 给出输出为 Compiled from Animal java class An
  • 如何在android中批量插入sqlite

    我正在使用 SQLiteOpenHelper 进行数据插入 我需要插入2500个id和2500个名字 所以花费了太多时间 请任何人帮助我如何减少插入时间 我们可以一次插入多条记录吗 任何人都可以帮助我 先感谢您 代码 public clas
  • 使用原始类型+大小写参数的 Swift Enum 的解决方法?

    我想创建 SKSpriteNodesWallType 请参阅下面的代码 并且仅当WallType is Corner通过它Side其方向的价值 枚举具有原始值 因为我需要将它们作为数字从 plist 加载 并能够随机创建它们 enum Si
  • 实体框架:在运行时更改连接字符串

    假设有一个 ASP NET MVC 应用程序使用 Entity Framework 6 和代码优先方法以及 StructureMap 作为 IoC 它还使用工作单元模式 域类 public class Product public int
  • 访问 PUT 或 POST 请求的原始正文

    我正在 Grails 中实现 RESTful API 并使用自定义身份验证方案 该方案涉及对请求正文进行签名 以类似于 Amazon 的 S3 身份验证方案的方式 因此 为了验证请求 我需要访问原始 POST 或 PUT 正文内容来计算和验
  • java BufferedReader 特定长度返回NUL字符

    我有一个 TCP 套接字客户端从服务器接收消息 数据 消息的类型为长度 2 个字节 数据 长度字节 由 STX 和 ETX 字符分隔 我使用 bufferedReader 检索前两个字节 解码长度 然后再次从同一个 bufferedRead
  • 有没有办法在javascript中代理(拦截)一个类的所有方法?

    我希望能够在类本身的构造函数内代理类的所有方法 class Boy constructor proxy logic do something before each call of all methods inside class like
  • 将每个数组的散点移动 delta x

    I m trying to sort out a plot which at the moment looks like this 我正在尝试找出如何针对不同的情况进行轮班dx每个数据集的值 在这种模式下 系列的最后一项保持在中心 在这种情
  • C 中的 fgets() 之后清除输入缓冲区

    include
  • 对话框片段嵌入取决于设备

    在我的应用程序中 用户从联系人或通话记录中选择电话号码 选择联系人非常简单 并且在手机和平 板电脑上都可以很好地工作 i e 在手机上会弹出新的全屏活动 在桌子上我会看到带有联系人列表的漂亮弹出对话框 似乎无法从通话记录中选择电话号码 因此
  • 更新每组单行

    的背景 我有一个临时表 其中包含唯一的 rowID OrderNumber 和 guestCount 等信息 RowID 和 OrderNumber 已存在于该表中 并且我正在运行一个新查询来填充每个 orderNumber 缺少的 gue
  • 为什么 useReducer 调度会导致重新渲染?

    假设我实现一个简单的全局加载状态 如下所示 hooks useLoading js import React createContext useContext useReducer from react const Context crea
  • JavaScript 支持逐字字符串吗?

    在 C 中 您可以像这样使用逐字字符串 server share file txt JavaScript中有类似的东西吗 模板字符串支持换行 so you can do this if you want https developer mo
  • Flex、AngularJS + Masonry、akoenig/angular-deckgrid 等 [重复]

    这个问题在这里已经有答案了 我一直在发送此电子邮件 我即将发布一个用于 Web 应用程序安全的应用程序 它需要使用像 Masonry 这样的网格 我已经尝试过所有的 每一个角度模块 指令和不同的方法 包括基于 CSS 的技术 纯 Vanil